如何将某行中的div设置为;“所有剩余空间”;使用css
如何将某行中的div设置为;“所有剩余空间”;使用css,css,xhtml,Css,Xhtml,我有以下代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css">
我有以下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.panel
{
border: 1px solid black;
background: #f2f2f2;
}
#after-top
{
position: absolute;
top: 90px;
left: 1px;
right: 1px;
font-size: 16px;
}
#languages
{
width: 120px;
text-align: center;
float: left;
}
#location
{
float: left;
margin: 0 1px 0 1px;
}
</style>
</head>
<body>
<div id="after-top">
<span class="panel" id="languages"><span>English</span> | <span>Русский</span></span>
<span class="panel" id="location"> </span>
</div>
</body>
</html>
面板
{
边框:1px纯黑;
背景#f2f2;
}
#顶后
{
位置:绝对位置;
顶部:90px;
左:1px;
右:1px;
字体大小:16px;
}
#语言
{
宽度:120px;
文本对齐:居中;
浮动:左;
}
#位置
{
浮动:左;
保证金:0 1px 0 1px;
}
英语
这会产生一些类似于:
+-------------------+ +-+
| English | Russian | | |
+-------------------+ +-+
+-------------------+ +--------------------------------------------------------+
| English | Russian | | |
+-------------------+ +--------------------------------------------------------+
+-------------------+ +------------------------------+
| English | Russian | | |
+-------------------+ +------------------------------+
+-------------------+ +-+
|英语|俄语| ||
+-------------------+ +-+
我想把第二个div拉伸到屏幕的末尾减去1px。比如: +-------------------+ +-+ | English | Russian | | | +-------------------+ +-+ +-------------------+ +--------------------------------------------------------+ | English | Russian | | | +-------------------+ +--------------------------------------------------------+ +-------------------+ +------------------------------+ | English | Russian | | | +-------------------+ +------------------------------+ +-------------------+ +--------------------------------------------------------+ |英语|俄语| || +-------------------+ +--------------------------------------------------------+ 当我放大屏幕时,我不希望出现如下效果: +-------------------+ | English | Russian | +-------------------+ +-----------------------------------------------------------+ | | +-----------------------------------------------------------+ +-------------------+ |英语|俄语| +-------------------+ +-----------------------------------------------------------+ | | +-----------------------------------------------------------+ 但是(当我升级窗口缩放时)类似于: +-------------------+ +-+ | English | Russian | | | +-------------------+ +-+ +-------------------+ +--------------------------------------------------------+ | English | Russian | | | +-------------------+ +--------------------------------------------------------+ +-------------------+ +------------------------------+ | English | Russian | | | +-------------------+ +------------------------------+ +-------------------+ +------------------------------+ |英语|俄语| || +-------------------+ +------------------------------+
您可以使用CSS3灵活的框,但它不适用于所有浏览器(即,我们正在关注您) HTML
<div id="container">
<div id="one">One</div>
<div id="two">Two</div>
</div>
示例:您可以使用CSS3灵活的方框,但它不适用于所有浏览器(即,我们正在关注您) HTML
<div id="container">
<div id="one">One</div>
<div id="two">Two</div>
</div>
示例:最好的解决方案是使用div而不是span:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.panel {
border: 1px solid black;
background: #f2f2f2;
}
#after-top {
position: absolute;
top: 90px;
left: 1px;
right: 1px;
font-size: 16px;
}
#languages {
width: 120px;
text-align: center;
float: left;
background: green;
}
#location {
background: red;
margin: 0 0 0 122px;
}
</style>
</head>
<body>
<div id="after-top">
<div class="panel" id="languages"><span>English</span> | <span>Русский</span></div>
<div class="panel" id="location"><span> </span></div>
</div>
</body>
</html>
.小组{
边框:1px纯黑;
背景#f2f2;
}
#顶后{
位置:绝对位置;
顶部:90px;
左:1px;
右:1px;
字体大小:16px;
}
#语言{
宽度:120px;
文本对齐:居中;
浮动:左;
背景:绿色;
}
#位置{
背景:红色;
利润率:0.122px;
}
英语
最好的解决方案是使用div而不是span:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.panel {
border: 1px solid black;
background: #f2f2f2;
}
#after-top {
position: absolute;
top: 90px;
left: 1px;
right: 1px;
font-size: 16px;
}
#languages {
width: 120px;
text-align: center;
float: left;
background: green;
}
#location {
background: red;
margin: 0 0 0 122px;
}
</style>
</head>
<body>
<div id="after-top">
<div class="panel" id="languages"><span>English</span> | <span>Русский</span></div>
<div class="panel" id="location"><span> </span></div>
</div>
</body>
</html>
.小组{
边框:1px纯黑;
背景#f2f2;
}
#顶后{
位置:绝对位置;
顶部:90px;
左:1px;
右:1px;
字体大小:16px;
}
#语言{
宽度:120px;
文本对齐:居中;
浮动:左;
背景:绿色;
}
#位置{
背景:红色;
利润率:0.122px;
}
英语
使用溢出:隐藏
:
#panel {
display: block;
}
#after-top, #location {
overflow: hidden;
}
#languages {
float: left;
}
使用溢出:隐藏
#panel {
display: block;
}
#after-top, #location {
overflow: hidden;
}
#languages {
float: left;
}