javascript - 将 span 元素对齐到 div 的左侧

标签 javascript jquery css

是否可以在这个 fiddle 中对齐跨度“Header”:http://jsfiddle.net/25LjE/37/在文本右侧,如图所示:

enter image description here

我正在使用 jquery 创建 header 。

这是 fiddle 代码:

<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>

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

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

当我在 IE8 中尝试建议的解决方案时,文本略高于其余文本:

enter image description here

这可以修复吗?

最佳答案

我不太清楚您要实现的目标,但添加此 CSS 似乎可以完成此任务:

center span{
    position:relative;
    top:30px;
    left:-70px;
}

关于javascript - 将 span 元素对齐到 div 的左侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11344882/

相关文章:

jQuery 在单选上显示一些内容

javascript - Tron 游戏关键事件问题

javascript - 查找使用 jQuery 的选择器

css - 为不同的浏览器加载不同的 CSS 是一种好技术吗?

html - css 网格元素上的粘性位置

javascript - Comet VS Ajax 轮询

javascript - 从服务器 Backbone.js 应用程序获取数据

javascript - 从实例方法调用实例方法

javascript - js.erb 不执行 javascript 但已处理 rails

css - 在容器内水平移动元素并居中对齐