【发布时间】:2013-04-07 11:57:53
【问题描述】:
编辑:添加 jsFiddle:http://jsfiddle.net/gdHuh/
在我的页面上有一个带有底部边框的标题。标题和边框之间有填充。浮动在标题区域右侧,触摸底部边框,是一个搜索框。这是它的样子:
但是,当标题和搜索框文字过长时,部分标题文字会被搜索框隐藏:
这就是我希望它在这种情况下的样子:
这是我的 HTML:
<div class="row">
<div class="column column8">
<h1>Internship Reviews & Rankings</h1>
</div>
<div class="findTop column column8">
<div class="greyShaded findTab">
<img class="verticalBottom" src="images/blueMagnify.png"/>
<a>Find an Internship Program</a>
<img class="verticalTextTop" src="images/greyArrowheadRight.png"/>
</div>
</div>
</div>
还有 CSS:
/* More Specific CSS */
.findTab{
float: right;
margin: 0px 5px;
padding: 5px 10px;
font-weight: bold;
line-height: 24px;
border-left: 1px solid #ddd;
border-top: 1px solid #ddd;
border-right: 1px solid #ddd;
background-color: #f5f5f5;
font-family: "Helvetica Neue", arial, helvetica, sans-serif;
font-size: 13px;
}
.findTop{
border-bottom: 1px solid #ddd;
margin-top: -23px;
}
/* More general CSS */
.row {
clear: both;
width: 100%;
position: relative;
}
.column {
margin: 0 15px;
float: left;
border: 0;
padding: 0;
position: relative;
}
.column8 {
width: 610px;
}
h1{
font-size: 28px;
line-height: 32px;
margin: 0px;
padding: 0px;
font-family: "Helvetica Neue", arial, helvetica, sans-serif;
font-weight: bold;
}
如何更改 HTML 和 CSS 以便正确布局元素?
【问题讨论】:
-
把这个工作示例放在一个小提琴中
-
要动态获得该行为,而不是使用预定义的宽度值,您需要使用 javascript。使用 CSS,您只能使用预定义的宽度值,这会在您更改链接文本时出现问题。
-
尝试使用自动换行link
标签: css positioning