我已经在JSfiddle中重新创建了它,仍然无法让它工作。我错过了什么?
这是HTML
<div class="row">
<div class="6u 12u$(small)"> <span class="image fit"><img src="images/pic01.jpg" alt=""></span>
<h2green class="h2green">HIDE IN PLAIN SIGHT</h2green>
<p>Escape to the big city of your choice; top floor of the tallest skyscraper with a champagne bottle in the bucket filled with ice, this might be just what you need .</p>
</div>
<div class="6u$ 12u$(small)"> <span class="image fit"><img src="images/pic02.jpg" alt=""></span>
<h2blue>ESCAPE TO THE COUNTRYSIDE</h2blue>
<p>You deserve a relaxing break and a quality experience. We strive to make it that way by finding you the right property and making sure you receive the very best of service before and during your stay.</p>
</div>
这里是CSS
h2green {
text-align: center;
font-family: Steelfish;
color: #80c342;
font-size: 3em;
}
h2blue {
text-align: center;
font-family: Steelfish;
color: #0080c6;
font-size: 3em;
}
所有文字总是与左边对齐,我需要它居中。
https://jsfiddle.net/m19f35nb/
我只想让所有H2s和Ps居中。
答案 0 :(得分:1)
HTML中没有<h2green>
或<h2blue>
这样的内容。为了从错误中恢复,浏览器正在生成内联元素(text-align
属性不适用于该元素。)
使用真实的HTML(<h2 class="blue">
)然后更改CSS以匹配:h2.blue
。
答案 1 :(得分:0)
这是HTML和CSS示例代码
<h2 class="blue">ESCAPE TO THE COUNTRYSIDE</h2>
<h2 class="green">ESCAPE TO THE COUNTRYSIDE</h2>
h2.green {text-align: center; font-family: Steelfish;color: #80c342;font-size: 3em;}
h2.blue { text-align: center; font-family: Steelfish; color: #0080c6; font-size: 3em; }