gpt4 book ai didi

html - 如何让屏幕中心的div不在右下角?

转载 作者:太空宇宙 更新时间:2023-11-03 20:34:45 29 4
gpt4 key购买 nike

下面是我想要的

enter image description here

这是我的 CSS 代码:

<html>
<header>
<style type="text/css">
*{margin:0 0 0 0;padding:0 0 0 0}
div.block{width:400px;height:121px;border:1px solid red;position:absolute;top:50%;left:50%;}
div.box{float:left;}
div img{margin:0px;padding:0;width:121px;height:121px;float:left;}
div.description{float:left;border 1px solid red;margin:10px 50px;}
</style>

</header>
<body>
<div class="block">
<div class="box"><img src="test.jpg" /></div>
<div class="description">
<p>music mane: xxxxxxxx</p>
<p>author: yyyyyyyy</p>
<p>publication:20081001</p>
<p>language:english</p>
</div>
</div>

</body>
</html>

这是test.img。

enter image description here

div在屏幕右下角,如何让它在屏幕中心?top:50%;left:50%;取不到结果。

enter image description here

最佳答案

试试这个

用这段代码替换“div.block”

div.block {
width: 400px;
height: 121px;
border: 1px solid red;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}

关于html - 如何让屏幕中心的div不在右下角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35145663/

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