html - header 不允许 <span> 在同一行中对齐

标签 html css

我有一个 css header ,不允许我使用 .我想 header 有一个奇怪的默认值,不允许我这样做,我该如何防止默认值或者我还可以使用什么来代替?

HTML

h3>Size:</h3>
<?php echo "<span class='sP'>".$pSize ."</span><br>"?>

CSS

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;

}

最佳答案

我认为这就是您正在寻找的答案 - 只需输入 display:inline-block 即可。我已经提供了一个带有答案的工作示例。请尝试一下,如果有任何问题请询问。

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;

}
<h3>Size:</h3>
<span class='sP'>hi</span><br>

关于html - header 不允许 <span> 在同一行中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44948451/

相关文章:

css - rails : Trying to get Bootstrap's offset class to work

html - 如何在 jquery mobile 中为可折叠集创建列表分隔符

javascript - 限制图片上传数量 JavaScript

html - 如何在不使用 span 的情况下更改元素符号的颜色?

html - CSS, float 框相互碰撞

javascript - 我可以在将鼠标悬停在另一个类上时向 div 添加一个类,而无需在 Ember 中使用 jQuery

javascript - 使用 HTML 的语义标记、定义列表或使用 div 的有序列表?

html - 使用 html 的 iframe 菜单

php - 是否有任何 html 模板引擎可以与 ruby​​ 和 php 一起使用?

javascript - 调整大小并使用 js 使用 resize() 方法实时查看结果