html - div 内的文本被压扁

标签 html css alignment

我设法获得一些帮助来正确对齐 div,我尝试将 3 个 div 堆叠在一起 3 次,将最多 9 个 div(每 3 个 div)堆叠在一起并包含信息...但是文本被压扁了向上。

我试图防止文本保持在相同的宽度内,这样它就不会被压扁并且看起来很整洁。

http://jsfiddle.net/Sk9HJ/ - HTML+CSS

<div class="contain-info">
<table>
<tr>
<td>
<div class="info1">
<h1>WHAT IS IT?</h1>
<p>The internet is a Network of computers that are all connecting to create the global World Wide Web. All domains within the World Wide Web follow strict standardized communication protocols.</p>
</div>
</td>
<td>
<div class="info2">
<h1>USES</h1>
<p>Internet makes many activities easy and possible, some of these include but not limited to transferring files, Research, e-mail, chatting, social networks. A lot of business is also done over the internet although it is more secure then general browsing, this can include banking, online shopping, and money transfer.</p>
</div>
</td>
<td>
<div class="info3">
<h1>CONNECTING</h1>
<p>Connecting to the internet Requires:
A Reasonably up-to-date computer
A Telephone line, Spare power point
Ethernet cable *If required*
There are two main ways to connect to the internet at home. The first and most popular one is broad band or WiFi. As said in the name Wireless is a no wired way of connecting to the internet. Second we have though Ethernet cable, an Ethernet cable is a cable that connects devices to each other to provide internet from routers.</p>
</div>
</td>
</tr>
</table>

.contain-info {
 display: inline-block;
 width:100%;
 position: relative;
 text-align: center;
 margin-left: auto;
 margin-right: auto;

 }
table {
    margin: 0px auto;

}
td {
    height: auto;

}
.info1 {
 font-family: "Bebas Neue";
 text-align: center;
  margin-left: 100px;
  margin-right: 100px;
 }

.info1 p {
 font-size: 20px;
 font-family: "Agency FB";
 }

.info1 h1 {
 font-size: 70px;
 color: #fff;
 text-shadow: 0px 3px 8px rgba(0, 0, 0, 0.6);
 font-weight: normal;

 }

.info2 {
 font-family: "Bebas Neue";
 text-align: center;
 margin-left: 100px;
 margin-right: 100px;

 }

.info2 p {
 font-size: 20px;
 font-family: "Agency FB";
 }

.info2 h1 {
 font-size: 70px;
 color: #fff;
 text-shadow: 0px 3px 8px rgba(0, 0, 0, 0.6);
 font-weight: normal;

 }

.info3 {
 font-family: "Bebas Neue";
 text-align: center;
  margin-left: 100px;
  margin-right: 100px;
 }

.info3 p {
 font-size: 20px;
 font-family: "Agency FB";
 }

.info3 h1 {
 font-size: 70px;
 color: #fff;
 text-shadow: 0px 3px 8px rgba(0, 0, 0, 0.6);
 font-weight: normal;
 }

最佳答案

查看此Fiddle

添加宽度:100%;

table{
    margin: 0px auto;
    width: 100%;
}

您可以添加td百分比,例如width: 33.33%;。您也可以使用 padding 代替左右边距: padding: 5px;

td {
    height: auto;
    width: 33.33%;
    padding: 5px;
}

关于html - div 内的文本被压扁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22449514/

相关文章:

javascript - 在 javascript 中处理 PHP 脚本

javascript - 取消隐藏表格行会导致表格跳转,如何解决这个问题?

jquery - Asp.net:带有 Jquery slider 问题的 Repeater

android - CSS 无法在设备上运行

html - 当所有边距都是 15px 时,我的元素应该放在哪里?

iphone - 按钮文本未对齐 Safari

javascript - 我如何用更少的 Javascript 行来表达这一点?

javascript - 如何通过单个 ajax 调用将同一文件中的不同 json 对象放置在不同的 div 中?

html - 无法在 CSS 中将图像居中

css - 如何将未知大小的图像居中放置在 div 中?