[英]How can I center my main blog content?
Currently my blog is split into two horizontal sections. 目前,我的博客分为两个水平部分。 The main content and a right-hand sidebar.
主要内容和右侧边栏。
I'd like to center the main content whilst reducing the width of the sidebar so I can keep it. 我想使主要内容居中,同时减小边栏的宽度,以便我可以保留它。
How can I do this? 我怎样才能做到这一点?
I've tried adding margin-left:16%
to .content
but I believe this is the incorrect way to do things. 我尝试将
margin-left:16%
到.content
但是我相信这是做事的不正确方法。
Demo at: https://www.moneynest.co.uk/how-to-choose-a-broker/ 演示在: https : //www.moneynest.co.uk/how-to-choose-a-broker/
Note: I'm running Wordpress with a custom genesis theme using Bootstrap. 注意:我正在使用Bootstrap运行具有自定义创世纪主题的Wordpress。
My stripped page code is: 我剥离的页面代码是:
<html>
<body class="post-template-default single single-post postid-594 single-format-standard logged-in admin-bar no-customize-support nolayout windows chrome override" itemscope itemtype="http://schema.org/WebPage"><div class="site-container">
<div class="site-inner">
<div class="content">
<div id="container">
<div class="central-container">
<div class="middle-content">
<div class="inner-post-head">
</div>
<div class="data-content">
<!--MAIN CONTENT HERE -->
</div><!-- End .middle-content -->
</div>
</div><!-- End #container -->
</div><!-- End #content -->
<aside class="sidebar sidebar-primary widget-area" role="complementary" aria-label="Primary Sidebar" itemscope itemtype="http://schema.org/WPSideBar" id="genesis-sidebar-primary"><h2 class="genesis-sidebar-title screen-reader-text">Primary Sidebar</h2><section id="text-9" class="widget widget_text"><div class="widget-wrap"> <div class="textwidget">
<!--SIDE BAR CONTENT HERE--></div>
<!--<div id="popular-articles">
<p class="popular-articles-text">Popular articles</p>
</div>-->
</div>
</div>
</div>
<section id="text-10" class="widget widget_text"><div class="widget-wrap"
</div></section>
</div>
</aside>
<!--END OF SIDEBAR--!>
<!--FOOTER STUFF-->
</body>
</html>
To center the .content div you can simply use: 要使.content div居中,您可以简单地使用:
.content{
margin:0 auto;
}
or 要么
.content {
margin-left:auto;
margin-right:auto;
}
The "auto" statement does the trick. “自动”语句可以解决问题。 ;)
;)
Make sure the missing bracket is not throwing things off. 确保缺少的支架不会丢东西。 I added the bracket to the code(indicated in bold)
我在代码中添加了括号(以粗体显示)
</div>
<section id="text-10" class="widget widget_text"><div class="widget-wrap"**>**
</div></section>
</div>
</aside>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.