3 div在同一条线上:左边和右边根据窗口大小改变它们的宽度,而居中是固定的

时间:2022-12-02 21:25:04

Maybe it is really simple but I can't get it.

也许这很简单,但我无法得到它。

I'd like the center of my 3 columns to have 1280 width and have the other two resized in function of the size of the windows (so if, for instance, the window is 1280px large, I can't see the side divs).

我希望我的3列的中心有1280宽度,并且其他两个在窗口大小的功能中调整大小(例如,如果窗口是1280px大,我看不到侧面div) 。

Here is my code. Where am I wrong?

这是我的代码。我哪里错了?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento senza titolo</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<style>

div{display:block;}


#left{
    border:1px solid green;
    float:left;
    width:auto;
    }
#center{
    border:1px solid red;
    width:1280px;
    float:left;
    }
#right{
    border:1px solid purple;
    float:left;
    width:auto;
    }

</style>
</head>

<body>
    <div id="container_center">
        <div id="left">&nbsp;</div>
        <div id="center">
        Lorem ipsum
        </div>
        <div id="right">&nbsp;</div>
    </div>

</body>
</html>

1 个解决方案

#1


0  

It would help if you gave us the url of this so we do not have to load it on our own, but I would start by adding a min-width:10px; and a min-height:100px. Possible starting with some lorem ipsum because some browsers might ignore your space.

如果你给我们这个url,这将有所帮助,所以我们不必自己加载它,但我会先添加一个min-width:10px;和最小高度:100px。可能从某些lorem ipsum开始,因为某些浏览器可能会忽略您的空间。

#1


0  

It would help if you gave us the url of this so we do not have to load it on our own, but I would start by adding a min-width:10px; and a min-height:100px. Possible starting with some lorem ipsum because some browsers might ignore your space.

如果你给我们这个url,这将有所帮助,所以我们不必自己加载它,但我会先添加一个min-width:10px;和最小高度:100px。可能从某些lorem ipsum开始,因为某些浏览器可能会忽略您的空间。