css - 侧栏和中间的文本使用内联样式

标签 css css-float

我应用了 html 代码和内联样式,2 列文本链接和每侧垂直图像。在中间我放了帖子的文本和内容。

如果帖子很大,当侧栏上没有足够的图像以将文本保持在中间时,文本将占据整个页面宽度。

我想将文本保留在这些列的中间。

  <div style="float: right; text-align: center;">

<p><strong>Version.V
   </strong></p>
  <p><strong> 999
    </strong></p>
  <p><strong>August 7, 2013</strong></p>
  <p>
    <a href="#">News</a>    </p>
  <p><a href="#">Updated
    News</a></p>
  <p>
    <a href="#">Old
    News</a></p>
    <p><a href="#">Posts</a></p>
    <p><a href="#">Daily News</a></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><a href="#"><img title="here" alt="here" src="picture.gif" width="150" height="97" /></a></p>
</div>

<div style="float: left; padding-right: 1px; text-align: center;">

  <p><strong>Version.V
   </strong></p>
  <p><strong> 999
    </strong></p>
  <p><strong>August 7, 2013</strong></p>
  <p>
    <a href="#">News</a>    </p>
  <p><a href="#">Updated
    News</a></p>
  <p>
    <a href="#">Old
    News</a></p>
    <p><a href="#">Posts</a></p>
    <p><a href="#">Daily News</a></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><a href="#"><img title="here" alt="here" src="picture.gif" width="150" height="97" /></a></p>
</div>
<div>


<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&rsquo;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br>
  <span id="more-208"> </span><br>
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&rsquo;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&rsquo;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&rsquo;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&rsquo;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

</div>
</body>
</html>

Text in the middle

往下越长,就会从页面边缘向左对齐,我希望它在中间的一个盒子里列。

最佳答案

在你的 p 标签中添加一个类来保存你的主要内容

FIDDLE

<p class="content">[main content here]</p>

CSS

.content
{
    width:100%;
    padding: 0 150px;
    box-sizing:border-box;
}

关于css - 侧栏和中间的文本使用内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18113697/

相关文章:

css - 在 CSS 动画结束时保持最终状态

Css 从顶部对齐文本框

html - 如何对齐多个 float 元素

html - 我们如何使用带有超链接标签的 Canvas 标签

javascript - 我将如何使用 javascript/jquery 进行两指拖动?

javascript - 如何使用 jQuery 在特定 CSS 文件之间切换?

html - css中[att|=val]和[att~=val]有什么区别

css - 为什么两个 float div 之一被推到下一行?

html - 侧边栏不会向右浮动

html - float 表格单元格