我正在尝试防止此 HTML 中的换行
http://jsfiddle.net/DD3v8/
碰巧当我调整窗口大小时,图标和文本都换行。我已经尝试过使用空格 CSS 属性。我也尝试过表格方法,但行为是相同的
谁能弄清楚发生了什么?
提前致谢
试试这个:
.line {
height: 44px;
width: 100%;
display: inline-block;
background-color: #6c7987;
white-space: nowrap;
position: relative;
}
.icon {
position: absolute;
left: 0;
height: 44px;
width: 90px;
background-color:
#FF0080;
color: white;
text-align: center;
line-height: 44px;
font-family: Arial;
float: left;
font-size: 12px;
font-weight: bold;
padding: 0;
}
.title {
position: absolute;
left: 90px;
color: white;
line-height: 44px;
text-align: left;
padding: 0 0 0 10px;
font-family: Arial;
float: left;
font-size: 12px;
display: inline;
white-space:nowrap;
}
.botoes {
position: absolute;
width: 300px;
right: 0
}
.botao {
width: 46px;
height: 45px;
float: right;
line-height: 44px;
text-align: center;
display: block;
white-space:nowrap;
cursor: pointer;
}
.botaoVerRecurso {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoVerRecurso:hover {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoEditarRecurso {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoEditarRecurso:hover {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoFavRecurso {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoFavRecurso:hover {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoPartRecurso {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoPartRecurso:hover {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoApagarRecurso {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.botaoApagarRecurso:hover {
background: url('http://www.think-cell.com/images/cross.png') center no-repeat;
}
.clear {
clear: both;
}
解释很简单:使用浮动时,你不能给支架放更多的宽度,它大于支架的高度,浮动会自动掉落它,并断线。
如果您使用仓位,请像这样使用它:
容器(位置:相对(
SUB元素(上:绝对,上:0,左:0(<放在左>
上角 SUB元素(posision:绝对,底部:0,右:0(<放在右下角>放在右下角>放在左>
在 W3C 中:http://www.w3schools.com/css/css_positioning.asp
正确理解您的问题,您需要能够在没有文本和"x"图标向下跳转的情况下调整窗口宽度的大小,是这样:
从.title
中删除 CSS
min-width: 500px;
看到这个小提琴的例子!