我使用的是代码:
<script>
jQuery('div.io-title-description').attr('align', 'center');
</script>
<style>
div.io-title-description { text-align: center; }
div.io-title-description a:first-child { font-size: 36; font-weight: bold; text-transform: uppercase; color: #1E73BE; text-shadow: 0px 0px; text-decoration: none; }
</style>
要对齐我的网站的页眉:https://news.softsolutionslimited.com
CSS代码将在jQuery
和CSS
中设置除align
之外的所有其他CSS属性
发布于 2020-05-02 10:53:41
我已经看过你的网站了。并且我对类做了一些更改:
.io-title-description {
display: inline-block;
margin: 17px 0;
padding: 14px 0;
float: none;
width: 75%; /* After width is given inline-block will align center */
box-sizing: border-box; /* padding included inside width */
}
.socialmedia {
float: right;
padding: 7px 10px;
text-align: right;
width: 25%;
margin-top: 30px;
box-sizing: border-box; /* Padding included */
}
我所做的更改,为.io-title-description
和border-box
添加了宽度。因为,我添加了宽度,inline-block
元素将知道行的宽度,如果没有其他元素,则它会将项目居中对齐。border-box
赋予元素填充,但填充包含在宽度内,即width
将始终相同(在本例中为75%)。
*注意:-我认为现在你不必添加jquery来对齐中心,因为你已经在parent中的某个地方使用过了。
https://stackoverflow.com/questions/61553781
复制相似问题