gpt4 book ai didi

javascript - 集中在水平元素 float ,如果可能的话,响应式

转载 作者:行者123 更新时间:2023-11-28 03:25:11 25 4
gpt4 key购买 nike

我在回答这个问题时遇到了问题。

当我减小窗口的宽度时,我试图使所有带有 div 的形状保持居中,但它们始终相互跟随,并且真正地向左(想想 float: left 确实如此)。

还有图片,如果可能的话,我们会保持对我感兴趣的响应式,但我试图控制宽度百分比但没有奏效。

感谢支持。

Fiddler

<div class="general-box">
<div class="left-right-padding">
<ul>
<li class="general-box-title">TITLE 1</li>
<li> <a id="" href="" title=""><img src="" width="156" height="75" alt="" /></a>
<a class="left-margin-photo" href="" title=""><img src="" width="101" height="75" alt="" /></a>

</li>
</ul>
</div>
<div class="left-right-padding">
<ul>
<li class="general-box-title">TITLE 2
<li> <a href="" title=""><img src="" width="92" height="75" alt="" /></a>
<a class="left-margin-photo" href="" title=""><img src="" width="160" height="75" alt="" /></a>

</li>
</ul>
</div>
<div class="left-right-padding">
<ul>
<li class="general-box-title">TITLE 3
<li> <a href="" title=""><img src="" width="170" height="75" alt="" /></a>
<a class="left-margin-photo" href="" title=""><img src="" width="88" height="75" alt="" /></a>

</li>
</ul>
</div>
<div class="clear"></div>
</div>

CSS:

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
outline: none;
text-decoration: none;
zoom: 1;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after, q:before, q:after {
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.clear {
clear: both
}
.general-box {
padding: 0 40px 30px 40px;
font-weight: bold;
border: 1px solid #000;
}
.general-box .left-right-padding {
float: left;
padding: 0 20px 0 20px;
}
.general-box .general-box-title {
margin: 30px 0 30px 0;
}
.general-box .left-margin-photo {
margin-left: 16px;
}

最佳答案

移除 float ,并放置

.general-box {
padding: 0 40px 30px 40px;
font-weight: bold;
display: table-row;
border: 1px solid #000;
}
.general-box .left-right-padding {
display: table-cell;
padding: 0 20px 0 20px;
}

并使用此 css 在内容周围添加一个 div:display: table 和 width: 100%

Fiddler

关于javascript - 集中在水平元素 float ,如果可能的话,响应式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21680263/

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