gpt4 book ai didi

html - 居中 div 并使其占据 80% 的屏幕

转载 作者:太空宇宙 更新时间:2023-11-04 04:33:23 24 4
gpt4 key购买 nike

我想让我的 div 居中并占据屏幕的 80%,在最大窗口大小下它工作正常但是当调整窗口大小时我的图像 div 变得非常小;

<body style="background-image:url('img/Mesh2.png');background-repeat:no-repeat; background-size: cover; width=:'100%'">
<h1>iSlider</h1>

<div id="myImageFlow" class="imageflow">

<div id="front">Initialy This is Front </div>
<!--
<img src="img/img1.png" id="id1" longdesc="img/img1.png" width="300" height="360" alt="img1" />
<img src="img/img2.png" id="id2" longdesc="img/img2.png" width="300" height="360" alt="img2" />
<img src="img/img3.png" id="id3" longdesc="img/img3.png" width="300" height="360" alt="img3" />
<img src="img/img4.png" id="id4" longdesc="img/img4.png" width="300" height="360" alt="img4" />
<img src="img/img5.png" id="id5" longdesc="img/img5.png" width="300" height="360" alt="img5" />
<img src="img/img6.png" id="id6" longdesc="img/img6.png" width="300" height="360" alt="img6" />
<img src="img/img7.png" id="id7" longdesc="img/img7.png" width="300" height="360" alt="img7" />
<img src="img/img8.png" id="id8" longdesc="img/img8.png" width="300" height="360" alt="img8" />
<img src="img/img9.png" id="id9" longdesc="img/img9.png" width="300" height="360" alt="img9" />
<img src="img/img10.png" id="id10" longdesc="img/img10.png" width="300" height="360" alt="img10" />
<img src="img/img11.png" id="id11" longdesc="img/img11.png" width="300" height="360" alt="img11" />
<img src="img/img12.png" id="id12" longdesc="img/img12.png" width="300" height="360" alt="img12" />
<img src="img/img13.png" id="id13" longdesc="img/img13.png" width="300" height="360" alt="img13" />
<img src="img/img14.png" id="id14" longdesc="img/img14.png" width="300" height="360" alt="img14" />
<img src="img/img15.png" id="id15" longdesc="img/img15.png" width="300" height="360" alt="img15" />
<img src="img/img16.png" id="id16" longdesc="img/img16.png" width="300" height="360" alt="img16" />
</div>

最佳答案

糟糕的代码。

您不应该使用内联样式,并且不支持 longdesc。

使用 CSS!

居中一个div:

.class{
width: 80%;
margin: 0 auto;
display: block;
}

如果您需要使用自定义属性,请使用 data-longdesc=""而不是(从不)longdesc。如果您的 80% div 在调整大小时变得太小,那是因为它是一个百分比。例如,使用 min-width: 300px。

关于html - 居中 div 并使其占据 80% 的屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16855092/

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