gpt4 book ai didi

css - 相同大小的 float 分区在彼此对齐时大小不同

转载 作者:太空宇宙 更新时间:2023-11-04 10:03:37 25 4
gpt4 key购买 nike

我正在尝试使 html 中的两个部分宽度相等。它们应该保持相同的宽度,当它们适合一行时,当它们在彼此下方对齐时也是如此。

示例在这里:sample

当两个盒子排成一排时,看起来不错:

a busy cat http://xn--audiobibelne-olb.wowogiengen.de/div_in_one_row.png

但是如果它们 float ,我的第二个 div 似乎比第一个小

two muppets http://xn--audiobibelne-olb.wowogiengen.de/div_in_one_column.png

这是页面的完整代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<style>

.container {margin:auto;}
.container-inner {position:relative;left:-50%;float:right}
.container-inner ul {position:relative;left:50%}
.container-inner li {display:inline;line-height:normal; }
.container-inner li div {display: table-row;}
.container-inner a,.container-inner a:visited {color:#525252;text-decoration:none}
.container-inner a:hover {text-decoration:underline}
.container-inner li:last-child {border-right:none}
.FarbeNT {background: rgba(255,128,0,0.5)}
.FarbeAT {background: rgba(0,255,0,0.5)}
</style>
</head>
<body>
<div class="container">
<div class="container-inner">
<ul>
<li>
<div class="FarbeAT">
<div style="background-color: rgba(0,0,0, 0.15);">
<a href="http://0_AudioBibel_NT_zip.zip">Das Neue Testament</a>
<a href="http://0_AudioBibel_NT_zip.zip"><img alt="0_AudioBibel_NT_zip.zip" src="audiobibelneu/assets/zip.png"/></a>
</div>
<div style="">
<p><a href="?Buch=evangelien_apostel">Evangelien &amp; Apostel</a></p>
<p><a href="?Buch=briefe">Briefe</a></p>
<p><a href="?Buch=offenbarung">Offenbarung</a></p>
</div>
</div>
</li>
<li style="display: inline">
<div class="FarbeNT">
<div style="background-color: rgba(0,0,0, 0.15)">
<a href="http://0_AudioBibel_AT_zip.zip" title="Das alte Testament komplett als ZIP-Datei.">Das Alte Testament</a>
<a href="http://0_AudioBibel_AT_zip.zip" title="Das alte Testament komplett als ZIP-Datei."><img alt="0_AudioBibel_AT_zip.zip" src="audiobibelneu/assets/zip.png"/></a>
</div>
<div style="">
<p><a href="?Buch=geschichte">Ge&shy;schichts&shy;büc&shy;her</a></p>
<p><a href="?Buch=poesie">Poetische Bücher</a></p>
<p><a href="?Buch=prophetie">Prophetische Bücher</a></p>
</div>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>

编辑于 2016-06-03 16:03 GMT+2:我的代码示例的唯一问题是,当它们像第二张图片那样堆叠时,橙色框似乎比绿色框小一点。

我找不到让两个盒子大小相等的方法,比如 15em 宽和 8em 高。

最佳答案

我删除了这一行

.container-inner li div {display: table-row;}

并更新了这个:

.container-inner li {display:inline-block;line-height:normal;float:left; }

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<style>

.container {margin:auto;}
.container-inner {position:relative;left:-50%;float:right}
.container-inner ul {position:relative;left:50%}
.container-inner li {display:inline-block;line-height:normal;float:left; }
.container-inner a,.container-inner a:visited {color:#525252;text-decoration:none}
.container-inner a:hover {text-decoration:underline}
.container-inner li:last-child {border-right:none}
.FarbeNT {background: rgba(255,128,0,0.5)}
.FarbeAT {background: rgba(0,255,0,0.5)}
</style>
</head>
<body>
<div class="container">
<div class="container-inner">
<ul>
<li>
<div class="FarbeAT">
<div style="background-color: rgba(0,0,0, 0.15);">
<a href="http://0_AudioBibel_NT_zip.zip">Das Neue Testament</a>
<a href="http://0_AudioBibel_NT_zip.zip"><img alt="0_AudioBibel_NT_zip.zip" src="assets/zip.png"/></a>
</div>
<div style="">
<p><a href="?Buch=evangelien_apostel">Evangelien &amp; Apostel</a></p>
<p><a href="?Buch=briefe">Briefe</a></p>
<p><a href="?Buch=offenbarung">Offenbarung</a></p>
</div>
</div>
</li>
<li style="display: inline">
<div class="FarbeNT">
<div style="background-color: rgba(0,0,0, 0.15)">
<a href="http://0_AudioBibel_AT_zip.zip" title="Das alte Testament komplett als ZIP-Datei.">Das Alte Testament</a>
<a href="http://0_AudioBibel_AT_zip.zip" title="Das alte Testament komplett als ZIP-Datei."><img alt="0_AudioBibel_AT_zip.zip" src="assets/zip.png"/></a>
</div>
<div style="">
<p><a href="?Buch=geschichte">Ge&shy;schichts&shy;büc&shy;her</a></p>
<p><a href="?Buch=poesie">Poetische Bücher</a></p>
<p><a href="?Buch=prophetie">Prophetische Bücher</a></p>
</div>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>

关于css - 相同大小的 float 分区在彼此对齐时大小不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38169505/

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