【发布时间】:2021-01-13 22:40:41
【问题描述】:
我正在开发一个聊天框,并试图将我的所有元素排列在一个 div 中(代码如下),但它只是中断并出现在它下面。为什么会这样以及如何解决?
非常欢迎任何建议或示例。
body {
background-color: #6B6B6B;
margin: 50px;
font-family: Arial;
color: darkgrey;
font-size: 14px;
line-height: .3;
letter-spacing: .5px;
}
.chattext {
font-family: Arial;
color: grey;
font-size: 12px;
line-height: 1.1;
letter-spacing: .5px;
}
.right {
right:15px;
}
/*............... chatbox ...............*/
.chatbox {
position: absolute;
width: 500px;
border-radius: 0px 0px 30px 30px;
background-color:rgba(0, 0, 0, .4);
}
input[type=text] {
width: 240px;
height: 40px;
border: none;
outline: none;
padding-left: 30px;
font-size: 14px;
color: lightgrey;
font-weight: bold;
font-style: italic;
letter-spacing: .5px;
background-color:transparent;
}
.bubble {
position: absolute;
max-width:200px;
padding: 15px;
padding-top: 0px;
border-radius: 0px 30px 30px 30px;
background-color:rgba(0, 0, 0, .3);
}
/*......... crossfade on buttons .........*/
.hover img{
transition:.3s;
position:absolute;
}
.nohover{
opacity:0;}
a:hover .hover{
opacity:0;
}
a:hover .nohover{
opacity:1;
}
<!--............ chatbox ..............-->
<div class="chatbox">
<!--........ emojis list ........-->
<div style="background:#2f2f2f;height:42px;"><a class="hover" href="emojis.htm"><img src="http://wizzfree.com/pix/smiley.png" width="33" style="margin-left:-20px;"><img src="http://wizzfree.com/pix/smiley2.png" width="33" class="nohover" style="margin-left:-20px;"><img src="http://wizzfree.com/pix/smiley.png" width="33" class="hover" style="margin-left:-20px;"></a>
<!--....... input message .......-->
<form><input type="text" id="fname" name="fname" value="Type Your Message" onFocus="this.value=''"></form>
<!--....... send button .......-->
<b style="margin-left:40px;size:16;line-height:2.9;"><i>Yummi is Typing... </i></b><a class="hover" href="send.htm"><img src="http://wizzfree.com/pix/button6.png" width="90"><img src="http://wizzfree.com/pix/button7.png" width="90" class="nohover"><img src="http://wizzfree.com/pix/button6.png" width="90" class="hover"></a></div>
<!--....... chatlines .......-->
<div style="height:200px"></div>
【问题讨论】:
-
您的 html 非常混乱,我不确定您希望它如何按原样处理您的代码。
-
当你有一个 css 文件时不要使用内联样式。它更难维护。
-
width="33"不工作。宽度需要类似px或em
标签: html css alignment margin divide