定位元件在特定高度

时间:2012-07-09 14:46:24

标签: javascript jquery css

在下面的小提琴中,“Header”(红色)文本略高于问题文本的其余部分。如何减少文本的高度?

我尝试过使用“top -30px”?

http://jsfiddle.net/25LjE/44/

.pds-pd-link {
display: none !important;
}
.pds-box {
    width: 220px !important;
}
.pds-input-label{
    width: auto! important;
}
.PDS_Poll{
    margin-bottom:15px;
}

<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6352993.js"></script>
<noscript><a href="http://polldaddy.com/poll/6352993/">This is very long test question to test how polldaddy handles questions that exceed that normal length............ yes a very long question indeed..............</a></noscript>

$(document).ready(function() {

    $('.pds-question-inner').prepend('<center><span style="color:red;font-weight:bold;font-size: 10pt;float:left"><u>Header</u></span></center>');
});

2 个答案:

答案 0 :(得分:2)

首先,不要浮动标题span范围。保持内联。所以从你的js中删除那个声明。

其次,问题是.pds-question-top元素上的填充顶部正在推动段落文本。尝试将其设置为零,一切看起来都很好。反正这很干净。我通常更喜欢用p元素的底部填充创建所有段落间距,而不是顶部填充,因此段落总是从我想要的地方开始。

见:

http://jsfiddle.net/25LjE/56/

答案 1 :(得分:0)

尝试line-height:或vertical-align