gpt4 book ai didi

html - DIV 未按预期定位

转载 作者:行者123 更新时间:2023-11-28 17:51:40 26 4
gpt4 key购买 nike

我的自制控制台有问题。

我有一张关于错误的图片。 Example

由于 div 的宽度,| 太远了。我不知道如何解决这个问题。感谢您的帮助。

我的代码:

HTML

<div class="container">
<div class="console">
<div class="console-body">
<div id="typer"></div><div id="typed-cursor">|</div>
</div>
</div>
</div>

CSS

body {
margin:0;
padding:0;
background-color:#262626;
}

.container {
max-width:800px;
margin-left:auto;
margin-right:auto;
}

.console {
position: fixed;
top: 50%;
left: 50%;
margin-top: -200px;
margin-left: -400px;
background-color:black;
width:800px;
height:400px;
border:solid 2px #444444;
overflow-y: auto;
}

.console #typer {
padding:0;
margin:0 0 0 5px;
color:#00FFFF;
display:inline-block;
}

#typed-cursor{
font-weight: 100;
display:inline-block;
}

怎么了?

仅供引用:该网站是假的,用于教育目的。

最佳答案

为了使行内 block 元素整齐地并排放置,您需要声明元素的宽度。在这种情况下,您最好将元素显示属性设置为 display:inline; 这将导致元素扩展到内容的大小,确保 cursortyper 很紧。

.console #typer {
padding:0;
margin:0 0 0 5px;
color:#00FFFF;
display:inline;
}


#typed-cursor{
opacity: 1;
font-weight: 100;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
-ms-animation: blink 0.7s infinite;
-o-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
display:inline;
}

或者,您可以将#typed-cursor 的宽度设置为 5px(或更小)。宽度:5px;

关于html - DIV 未按预期定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22196597/

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