2 CSS 中盒子内有盒子

发布于 2024-12-25 04:40:39 字数 1020 浏览 0 评论 0原文

我希望有人能为我提供一个有效的 css,它可以将 2 个盒子放入一个盒子中。 就像我给出的图像

这就是我想要的样子 CSS

<style type="text/css">
            #adbox {
                width: 602px;
                height: 250px;
                border-width: 0;
                border-color: red;
            }
            #adbox .adbox1 {
                width: 300px;
                height: 250px;
                border-width: 0;
                border-color: red;
                }
            #adbox .adbox2 {
                width: 300px;
                height: 250px;
                border-width: 0;
                border-color: red;
        }
    </style>

HTML

<div align=center><div id="adbox">
<div class="adbox1">
<img src="foobar1.jpg" border="0" />
</div>
<div class="adbox2">
<img src="foobar.jpg" border="0" />
</div>
</div></div>

I would like some one to provide me with a valid css which can put 2 Boxes inside a box.
like in the image I have given

This is what I want it to look like
CSS

<style type="text/css">
            #adbox {
                width: 602px;
                height: 250px;
                border-width: 0;
                border-color: red;
            }
            #adbox .adbox1 {
                width: 300px;
                height: 250px;
                border-width: 0;
                border-color: red;
                }
            #adbox .adbox2 {
                width: 300px;
                height: 250px;
                border-width: 0;
                border-color: red;
        }
    </style>

HTML

<div align=center><div id="adbox">
<div class="adbox1">
<img src="foobar1.jpg" border="0" />
</div>
<div class="adbox2">
<img src="foobar.jpg" border="0" />
</div>
</div></div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荒岛晴空 2025-01-01 04:40:39

我猜您想像您提供的图像中那样对齐框。

您可以使用以下 css 来执行此操作:

#adbox {
  width: 600px;
  height: 250px;
  border: 1px red solid;
}

#adbox .adbox1, #adbox .adbox2 {
  width: 300px;
  height: 250px;
  float: left;
  outline: 1px red solid;
}

示例:http://tinkerbin.com/5MAX3Mt2

I'm going to guess that you want to align the boxes like in the image you provided.

You can do this with this css:

#adbox {
  width: 600px;
  height: 250px;
  border: 1px red solid;
}

#adbox .adbox1, #adbox .adbox2 {
  width: 300px;
  height: 250px;
  float: left;
  outline: 1px red solid;
}

Example: http://tinkerbin.com/5MAX3Mt2

甜`诱少女 2025-01-01 04:40:39

嗯..你没有问这个问题....我假设你想将两个盒子并排放置,我根据我的假设提供答案。如果您想将两个框并排放置,请按如下方式更改 html 和 css

另请注意“clear”类的用法,该类会清除浮动

html

<div align=center><div id="adbox"> 
<div class="adbox1"> 
<img src="foobar1.jpg" border="0" /> 
</div> 
<div class="adbox2"> 
<img src="foobar.jpg" border="0" /> 
</div> 
<div class="clear"/>
</div></div>

CSS

#adbox {   
            width: 602px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;   
        }   
        #adbox .adbox1 {   
            width: 300px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;  
            float:left; 
            }   
        #adbox .adbox2 {   
            width: 300px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;   
            float:left;
    }   
    .clear{
         clear:both;
    }

Well..You didn't ask the question....I am assuming that you want to place the two boxes side by side and I am providing answer based on my assumption. Change your html and css as below if you want to place the two boxes side by side

Also note the usage of "clear" class which clears the floats

html

<div align=center><div id="adbox"> 
<div class="adbox1"> 
<img src="foobar1.jpg" border="0" /> 
</div> 
<div class="adbox2"> 
<img src="foobar.jpg" border="0" /> 
</div> 
<div class="clear"/>
</div></div>

CSS

#adbox {   
            width: 602px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;   
        }   
        #adbox .adbox1 {   
            width: 300px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;  
            float:left; 
            }   
        #adbox .adbox2 {   
            width: 300px;   
            height: 250px;   
            border-width: 0;   
            border-color: red;   
            float:left;
    }   
    .clear{
         clear:both;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文