gpt4 book ai didi

html & css - 在精确坐标处定位 div

转载 作者:行者123 更新时间:2023-11-28 10:32:40 24 4
gpt4 key购买 nike

我正在尝试用纯 html 和 css 重新创建此图像,或者如果需要的话添加一点 javascript:

LCARS image

这是我目前所拥有的:

jeffs beautiful unfinished handywork

我试图将靠近中心的橙色小框向上移动以匹配蓝线,但她不会让步

.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 471px;
}

这是完整的代码:

布局.html

<html>
<head>
<title>LCARS</title>
<link rel="stylesheet" href="static/style.css"/>
</head>

<body>
<div class="topleft">
</div>

<div class="topleft2">
</div>

<div class="middletop">
</div>

<div class="bottomleft">
</div>

<div class="bottomleft2">
</div>

<div class="bottomleft3">
</div>

<div class="bottomleft4">
</div>

<div class="content">
</div>

<div class="content2">
</div>

</body>

<footer>


</footer>
</html>

样式.css

body {
background-color: black;
}

.topleft {
background-color: #c498c4;
width: 126px;
height: 90px;
}

.topleft2 {
margin-top: 5px;
background-color: #9b98fe;
width: 463px;
height: 112px;
border-radius: 0 0 0 70px;
}

.bottomleft {
margin-top: 7px;
background-color: #cc6061;
width: 463px;
height: 91px;
border-radius: 70px 0 0 0;
}

.bottomleft2 {
margin-top: 5px;
background-color: #cc6061;
width: 126px;
height: 137px;
}

.bottomleft3 {
margin-top: 5px;
background-color: #fe9800;
width: 126px;
height: 38px;
}

.bottomleft4 {
margin-top: 5px;
background-color: #ffa873;
width: 126px;
height: 180px;
}

.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 471px;
}

.content {
background-color: /*#6D6A6A*/black;
position: absolute;
left: 127px;
top: 239px;
border-radius: 35px;
width: 900px;
height: 700px;
}

.content2 {
background-color: black;
position: absolute;
left: 127px;
top: -2;
border-radius: 0 0 0 35px;
width: 900px;
height: 200px;
}

最佳答案

虽然我建议广泛使用绝对定位,但如果您已经在使用并且对它感到满意,那么您只需设置 top 就可以了:

.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 476px;
top:199px /* <-- this is what I added */
}

Here is a demo.

关于html & css - 在精确坐标处定位 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23460291/

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