과제에 대한 채팅 앱을 제작 중이며 거의 완료되었지만 채팅 상자의 텍스트가 하단에 정렬되지 않는 것 같습니다. 나는 vertical-align:bottom
과 display:table-cell
및 display:block
을 시도했지만 아무 소용이 없습니다.이상한 html과 css 구조가 있습니다. 어떻게하면 채팅 메시지를 맨 아래에 맞출 수 있습니까?
HTML을
<body>
<div id="wrapper">
<!-- title of app -->
<div id = "title">
<h2>SENG 513 Chat</h2>
</div>
<!--username-->
<div id="usernameIndicator">
</div>
<div id ="currentOnline">
<p>Currently Online</p>
</div>
<!--chat messages and online users-->
<div id ="main">
<div id="messageArea">
<ul id="messages"></ul>
</div>
<div id ="clear">
</div>
<div id ="usernames">
</div>
</div>
<!--chat and message bar-->
<form action ="">
<input id="m" autocomplete="off"/>
<button>Send</button>
</form>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script src="/client.js"></script>
</body>
CSS 당신은 당신이 필요로 무엇을 달성하기 위해 위치를 사용할 필요가
body, div, h1, h2, h3, h4, h5, h6, p, ul, img {
margin:0px; padding:0px;.
}
body{
font-family:helvetica;
}
#wrapper{
background-color:#3a6db7;
padding: 10px 30px 0px 30px;
margin:auto;
height:100%;
}
#title {
/*background-color:#4286f4;*/
text-align:center;
color:white;
}
#usernameIndicator h2
{
color:blue;
float:left;
width:90%;
}
#currentOnline{
}
#main
{
height:300px;
}
#messageArea{
width:90%;
height:100%;
background-color:#ffffff;
float:left;
overflow:auto;
display:block;
border: 1px solid;
}
#messages{
vertical-align:bottom;
display:table-cell;
}
#messages li {
padding: 5px 10px;
}
#messages li:nth-child(odd) {
background: #eee;
}
#usernames{
height:100%;
background-color:#e5e5e5;
border: 1px solid;
width:9%;
float:left;
overflow:auto;
}
#messagebarArea{
width:100%;
}
#form{
width:100%;
}
form input {
width:90%;
margin-top:20px;
margin-bottom:20px;
}
form button {
width: 9%;
background: rgb(130, 244, 255);
}
감사합니다, 그것은 텍스트 - 근무 된 DIV와 CSS (등 - 디스플레이 = 테이블, 테이블 셀)로 테이블을 생성 정렬하지만 채팅 메시지 영역에 문제가 있습니다. 스크롤 막대가 오버플로되면 더 이상 존재하지 않습니다. 스크롤 바가 필요해. – SolidSnake
CSS Positioning Tutorial 링크가 업데이트되었습니다. – CreativeDip