html - 如何将 p 标签的位置向上移动而不是在底部?

标签 html css

这是 JSFiddle 示例。我想移动 p 标签,使其内联显示在顶部,而不是底部。

<!DOCTYPE html>
<html>
<head>
<style>
div {
    display: inline;
}

p {
    border-bottom: 6px solid red;
    background-color: lightgrey;
    padding: 10px;
    max-width: 100px;
    display: inline-block;
    margin-right: 10px;
    max-height: 200px;
    font-family: "Arial";
}

p:hover {
    background-color: #CCCCCC;
    cursor: pointer;
}
</style>
</head>
<body>
<div>
    <p>This property is a shorthand property for border-bottom-width, border-bottom-style, and border-bottom-color.</p>

    <p>This property is a shorthand property for border-bottom-width, border-bottom-style, and border-bottom-color.</p>

    <p>This property is a shorthand property for border-bottom-width.</p>
</div>

</body>
</html>

https://jsfiddle.net/om7orw9w/

最佳答案

看起来你只是想使用 vertical-align 属性,设置为 top

div {
	display: inline;
}

p {
    border-bottom: 6px solid red;
    background-color: lightgrey;
    padding: 10px;
    max-width: 100px;
    display: inline-block;
    margin-right: 10px;
    max-height: 250px;
    font-family: "Arial";
    vertical-align: top;
}

p:hover {
	background-color: #CCCCCC;
    cursor: pointer;
}
<div>
  <p>This property is a shorthand property for border-bottom-width, border-bottom-style, and border-bottom-color.</p>
    
  <p>This property is a shorthand property for border-bottom-width, border-bottom-style, and border-bottom-color.</p>
    
  <p>This property is a shorthand property for border-bottom-width.</p>
</div>

关于html - 如何将 p 标签的位置向上移动而不是在底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43099620/

相关文章:

javascript - 从第二级 iframe 中选择根文档

html - 以反转颜色混合混合模式

html - 如果收到的电子邮件是垃圾邮件,则向用户显示一条消息

html - 如何从多个类别中选择第 n 个类型?

css - 使用 Less/CSS 同时为所有选择器设置样式链接(<a> 标签)?

html - 为什么 <hr/> 的颜色没有变化?

css - <label> 标签和输入不会换行

javascript - 在这个例子中如何输出 HTML?

jquery - 是否有一个 jQuery 插件可以用复选框数组填充一个元素?

javascript - 音频与onmousedown一起在Javascript/CSS中切出过早