html或css来调整和格式化博客文章的宽度

时间:2018-06-04 05:28:54

标签: html css

我的网站上的代码有些困难。现在,我的博客文章遍历内容页面的整个宽度并居中。

我希望文本左对齐,每边都有相等的边距,并使博客内容的宽度更窄,因此每行的字符数更少......就像这样example blog post

我希望每篇博文都以相同的格式发布,但我尝试的所有内容似乎都不起作用?我不确定我应该更改或添加什么css / html。我已经尝试了盒子大小调整,证明以及调整边距但是它没有给我这个结果我正在寻找并且我不确定采取什么步骤。任何帮助,将不胜感激。

谢谢!

2 个答案:

答案 0 :(得分:1)

您应该创建新的<div id="test">元素并将文本放入其中。为该div添加以下CSS:

#test{
width: 680px; /* adding width of text field */
margin: 0 auto; /* centering it */
text-align: left; /* aligning text to left side */

font-size: 15px; /* size of your font */
line-height: 24px; /* space between two lines */
letter-spacing: -0.01em; /* space between two letters */
/* By playing with values of last 3 lines you can make text look exactly how you want, I tried to mimic site that you posted as much as I could (I c/p-ed their CSS for text) */
}

答案 1 :(得分:0)

您可以使用Bootstrap类。它真的会帮助你很多。 它的'容器级别将为您提供相同的保证金 (你可以在这里看到例子https://getbootstrap.com/docs/4.0/layout/overview/

它的网格类将帮助您设置左右两部分(请参阅链接https://getbootstrap.com/docs/4.0/layout/grid/)。

希望这会对你有所帮助。