Html 使用css对div元素进行排序 聊天 在线用户: 创建聊天室后台大厅 发送
我需要始终在顶部div id=“页眉”,总是在ButoDIV类=“in PultCube”和中间(占据页面的其余部分)div类=“聊天区”,没有div类=“聊天区”重写,或者被div id=“页眉”或div类=“in PultCube”重写。有人知道做这件事的css代码吗 使用Html 使用css对div元素进行排序 聊天 在线用户: 创建聊天室后台大厅 发送,html,css,Html,Css,我需要始终在顶部div id=“页眉”,总是在ButoDIV类=“in PultCube”和中间(占据页面的其余部分)div类=“聊天区”,没有div类=“聊天区”重写,或者被div id=“页眉”或div类=“in PultCube”重写。有人知道做这件事的css代码吗 使用flexbox,这很容易实现 将包含3个隔间的包装设置为display:flex和 将其高度设置为100%或100vh。包装纸的高度将改变 填充整个高度,然后显示:flex将导致所有 具有适当flex属性的此包装的子项 (
flexbox
,这很容易实现
将包含3个隔间的包装设置为display:flex代码>和
将其高度设置为100%或100vh
。包装纸的高度将改变
填充整个高度,然后显示:flex代码>将导致所有
具有适当flex属性的此包装的子项
(例如flex:1;
)使用flexbox magic进行控制
示例标记:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="header">
<h1 id="titleRoom"></h1>
<h3>Online Users:</h3>
<div id="online_users"></div></br>
<button id="buttonRoom" type="button" name="button">Create Chatroom</button><button id="buttonLobby" type="button" name="button">Back Lobby</button></div>
<div class="chatArea">
<ul class="messages"></ul>
</div>
<div class='inputContainer'>
<input class="inputMessage" placeholder="Type here..."/><button id="sendButton" type="button" name="button">Send</button>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/client.js"></script>
</body>
</html>
一个快速的谷歌搜索就可以了。。但是给你。一种方法
正文{
填充顶部:60px;
填充底部:40px;
}
#标题,
#页脚{
宽度:100%;
位置:固定;
背景:#333;
填充:10px0;
颜色:#fff;
}
#标题{
排名:0;
}
#页脚{
底部:0;
}
.查特区{
宽度:80%;
保证金:0自动;
}
聊天
在线用户:
创建聊天室后台大厅
发送
Flexbox来救援
使用你的结构。颜色编码
body{display:flex;flex-direction:column;height:100vh;}
#标题{高度:100px;背景:绿色;}
.chatArea{flex-grow:1;align-self:stretch;background:blue;}
.inputContainer{height:100px;align self:flex end;width:100%;background:red;}
聊天
在线用户:
创建聊天室后台大厅
发送
聊天
博杜伊{
宽度:100%;
身高:100%;
}
.集装箱{
位置:相对位置;
高度:250px;
宽度:400px;
边框样式:虚线;
左:100px;
顶部:200px;
}
#标题{
文本对齐:居中;
}
#钮扣{
位置:相对位置;
文本对齐:居中;
}
#纽扣间{
位置:相对位置;
边界半径:5px;
背景颜色:白肋木;
}
#纽扣似的{
位置:相对位置;
边界半径:5px;
背景颜色:白肋木;
}
.输入容器{
位置:相对位置;
边缘顶部:30px;
文本对齐:居中;
}
#发送按钮{
位置:相对位置;
边缘顶部:20px;
文本对齐:居中;
}
在线用户:
创建聊天室后台大厅
发送
尝试使用position
将css添加到问题中标记中有一些错误,但有些元素没有balanced@Danix-如果我的回答对你有帮助,你能接受吗?:)
<div class="wrapper">
<header>I'm a 30px tall header</header>
<main>I'm the main-content filling the void!</main>
<footer>I'm a 30px tall footer</footer>
</div>
.wrapper {
height: 100vh;
display: flex;
/* Direction of the items, can be row or column */
flex-direction: column;
}
header,
footer {
height: 30px;
}
main {
flex: 1;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat</title>
<link rel="stylesheet" href="css/style.css">
<style>
boduy{
width: 100%;
height: 100%;
}
.container{
position: relative;
height: 250px;
width:400px;
border-style: dashed;
left:100px;
top:200px;
}
#header{
text-align: center;
}
#buttons{
position: relative;
text-align: center;
}
#buttonRoom {
position:relative;
border-radius: 5px;
background-color: burlywood;
}
#buttonLobby{
position:relative;
border-radius: 5px;
background-color: burlywood;
}
.inputContainer{
position:relative;
margin-top: 30px;
text-align: center;
}
#send-button{
position:relative;
margin-top: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div id="header">
<h1 id="titleRoom"></h1>
<h3>Online Users:</h3>
</div>
<div id="online_users"></div>
<div id="buttons">
<button id="buttonRoom" type="button" name="button">Create Chatroom</button><button id="buttonLobby" type="button" name="button">Back Lobby</button>
</div>
<div class='inputContainer'>
<textarea id="text-area" rows="5" cols="50" placeholder="Type here..."></textarea>
</div>
<div id="send-button">
<button id="sendButton" type="button" name="button">Send</button>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/client.js"></script>
</div>
</body>
</html>