gpt4 book ai didi

html - 漂浮在容器 Div 之外的 block

转载 作者:行者123 更新时间:2023-11-28 09:59:37 24 4
gpt4 key购买 nike

我的网页出现以下问题:enter image description here

如您所见,内部 div 元素漂浮在其容器之外。我在这里看到了一些关于使用

display:inline-block;

我尝试了一些变体,但没有成功。如果我在我的#container 和我的#itemWrapper 上都将显示设置为内联 block ,那么我的中心面板上的边距就会丢失,但是如果我在我的画廊上将显示设置为内联 block ,那么什么也不会发生,这里有点困惑。

HTML:

<body>

<div id="wrapper">

<section id="header">

<div class="logo">

<h1 id="logoText">Dope Clothing</h1>

</div>

</section>

<section id="nav">

<div id="nav-wrapper">

<ul id="nav-list">

<li id="nav-home"><a href="">Home</a>
</li>
<li id="nav-brands"><a href="">Brands</a>
<ul id="brands-list">
<li><a href="">Brand01</a>
</li>
<li><a href="">Brand02</a>
</li>
<li><a href="">Brand03</a>
</li>
<li><a href="">Brand04</a>
</li>
<li><a href="">Brand05</a>
</li>
</ul>
</li>
<li id="nav-about"><a href="">About Us</a>
</li>
<li id="nav-contact"><a href="">Contact Us</a>
</li>

</ul>

</div>

</section>

<section id="main">

<div id="content">

<div id="gallery">

<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>
<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>
<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>
<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>
<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>
<div class="itemWrapper">
<div class="pictureWrapper"><img class="itemPicture" src="Images/Clothing/green.png"/></div>
<div class="itemDetails">
<div class="itemTitle">Naartjie Fresh</div>
<div class="itemPrice">R150.00</div>
</div>
</div>

</div>

</div>

<aside id="share-wrapper">
<div id="sharebutton">></div>

<div id="share">
<div class="share-box"><div class="facebook-share">f</div></div>
<div class="share-box"><div class="twitter-share">t</div></div>
<div class="share-box"><div class="google-share">g</div></div>
<div class="share-box"><div class="insta-share">i</div></div>
</div>

</aside>

</section>

CSS:

* { margin:0; padding:0; }

#header,
#footer {
background-color: #000000;
}

#header { padding-top:50px; padding-left:50px; padding-bottom:20px; }

#logoText { color:#FFFFFF; font-size:54px; }

#nav-wrapper { padding-top:40px; text-align:center; }

#nav-list { display:inline; }

#nav-list li { display:inline-block; margin-right:30px; padding-right:30px; }

#nav-list li a { text-decoration:none; color:black; font-size:20px; }

#nav-list li a:hover { color:#CECECE;}

#nav-home, #nav-brands, #nav-about { border-right:thin solid black; }

#nav-brands { position:relative; }

#nav-list li:hover ul { display: block; opacity: 1; visibility: visible; }

#brands-list { padding: 10px 0px 0px 0px; position: absolute; top: 20px; left: -35px; width: 120px; box-shadow: none; display: none; opacity: 0;
visibility: hidden; -webkit-transiton: opacity 0.2s; -moz-transition: opacity 0.2s; -ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s; -transition: opacity 0.2s; border:thin solid #000000; border-radius:0px 0px 5px 5px;
border-top:0px;
}

#brands-list li { display: block; margin:0px 0px 5px 0px; padding:0px 0px 5px 0px; text-align:center; border-bottom:thin solid #CECECE;

}

#brands-list li:hover {}

#brands-list li:last-child { border-bottom:0px; }

#content {
width:1080px;
margin:10px auto;
border-left:thin groove #333;
}

#share-wrapper {
float:left;
width:40px;
height:180px;
}

#share {
border:thin solid #333;
border-left:0px;
border-radius:0px 6px 6px 0px;
width:30px;
padding:0px 5px;
height:170px;
}

#sharebutton {
color:#eeeeee;
height:20px;
width:30px;
text-align:center;
line-height:20px;
}

.share-box,
.share-box img {
width:30px;
height:30px;
}

.facebook-share,
.twitter-share,
.google-share,
.insta-share { width: 100%; height: 100%; line-height: 30px; text-align: center; color:#333; border:thin solid #333; border-radius:15px; margin:10px 0px; background-color:#eee;}

.facebook-share:hover,
.twitter-share:hover,
.google-share:hover,
.insta-share:hover { background-color:#333; color:#eee; }

.share-box img {

}

#content { margin:0px auto; max-width:1080px; border:0px;}

.itemWrapper { max-width:280px; float:left; margin:10px;}

.itemPicture { max-height:280px; max-width:280px; }

.itemTitle { text-align: center; font-size: 24px; font-weight: bold; }

.itemPrice { text-align: center; font-size: 18px; font-weight: bold; }

#footer { color:#cecece; padding:20px;}

#facebook { width:20px; height:20px; text-align:center; border-radius:10px; border:1px solid #cecece; }

编辑::::::::::::

好的,所以将 display:inline-block 添加到我的 #gallery div 而没有 item-wrapper 上的 inline-block 似乎可以解决问题,但是我似乎仍然无法让共享框出现在旁边 ??

最佳答案

在元素具有浮点值的层内创建一个空白 div 并应用:

clear: both;

关于html - 漂浮在容器 Div 之外的 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24763659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com