gpt4 book ai didi

html - 如何在 HTML/CSS 中完成这个布局?

转载 作者:太空宇宙 更新时间:2023-11-03 19:49:12 26 4
gpt4 key购买 nike

为什么 float 元素没有正确排列?我的图像有一些空白,我不知道它来自哪里。

想要的外观:

enter image description here

代码:

.inner-wrapper { float: left; width: 100%; color: #000; }

.feature-1 { float: right; margin: 0 auto; width: 50%; height: auto; }
.aside-image-1 { float: left; margin: 0 auto; height: auto; width: 50%; }

.feature-2 { float: left; margin: 0 auto; width: 50%; height: auto; }
.aside-image-2 { float: right; margin: 0 auto; height: auto; width: 50%; }

.feature-3 { float: right; margin: 0 auto; width: 50%; height: auto; }
.aside-image-3 { float: left; margin: 0 auto; height: auto; width: 50%; clear: both; }
<section class="inner-wrapper">
<aside class="aside-image-1">
<img src="https://s13.postimg.org/xsvgi16hv/feature_1.jpg" title="someText" alt="someText">
</aside>
<article class="feature-1">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>
<section class="inner-wrapper">
<aside class="aside-image-2">
<img src="https://s13.postimg.org/t89a33msj/feature_2.jpg" title="someText" alt="someText">
</aside>
<article class="feature-2">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>
<section class="inner-wrapper">
<aside class="aside-image-3">
<img src="https://s13.postimg.org/9ex6ae9er/feature_3.jpg" title="someText" alt="someText">
</aside>
<article class="feature-3">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>

最佳答案

检查这个...

使图像的宽度为 100%,文本居中

.inner-wrapper {
float: left;
width: 100%;
color: #000;
}
.feature-1 {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
text-align: center;
}
.aside-image-1 {
float: left;
margin: 0 auto;
height: auto;
width: 50%;
}
.feature-2 {
float: left;
margin: 0 auto;
width: 50%;
text-align: center;
height: auto;
}
.aside-image-2 {
float: right;
margin: 0 auto;
height: auto;
width: 50%;
}
.feature-3 {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
text-align: center;
}
.aside-image-3 {
float: left;
margin: 0 auto;
height: auto;
width: 50%;
clear: both;
}
.aside-image-1 img {
width: 100%;
float: left;
}
.aside-image-2 img {
width: 100%;
float: left;
}
.aside-image-3 img {
width: 100%;
float: left;
}
<section class="inner-wrapper">
<aside class="aside-image-1">
<img src="https://s13.postimg.org/xsvgi16hv/feature_1.jpg" title="someText" alt="someText">
</aside>
<article class="feature-1">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>
<section class="inner-wrapper">
<aside class="aside-image-2">
<img src="https://s13.postimg.org/t89a33msj/feature_2.jpg" title="someText" alt="someText">
</aside>
<article class="feature-2">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>
<section class="inner-wrapper">
<aside class="aside-image-3">
<img src="https://s13.postimg.org/9ex6ae9er/feature_3.jpg" title="someText" alt="someText">
</aside>
<article class="feature-3">
<h3>In-Store Interactive Tablet</h3>
<p>Shoppers can use Sellr's Help Me Choose feature to</p>
</article>
</section>

关于html - 如何在 HTML/CSS 中完成这个布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40970609/

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