首页 > 解决方案 > html 或 css 来调整和格式化博客文章的宽度

问题描述

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

我希望文本左对齐,每边的边距相等,并使博客内容的宽度更窄,因此每行的字符更少..就像这个示例博客文章

我希望使每篇博客文章都采用相同的格式,但我尝试过的一切似乎都不起作用?我不确定我应该更改或添加什么 css/html。我已经尝试过调整框大小、调整边距以及调整边距,但它并没有给我我正在寻找的结果,而且我不确定要采取什么步骤。任何帮助,将不胜感激。

谢谢!

标签: htmlcss

解决方案


您应该创建新<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) */
}

推荐阅读