css - 显示块不工作没有浮动清除两者
问题描述
我希望我的超人在上划线下方,只要超人如此,超人始终是一条线,我希望容器能够伸展。这太紧张了哈哈哈。我通读了大多数 SO 问题,告诉我要清除并清除两者,我知道 div 默认阻止我不知道该怎么做。哭哭。对不起,如果这是重复的或我来自 Photoshop Island 的任何内容。
body {background-color: darkslategrey;}
.img
{
display:inline-flex;
width:50;
height:50;
margin: auto;
}
.overline
{ display: inline-block;
vertical-align:top;
font-family: 'Helvetica';
padding-left: 5px;
padding-top: 5px;
font-size: .75em;
text-transform: uppercase;
letter-spacing: 1.5px;
height: auto;
}
.content
{ display: inline-block;
vertical-align:bottom;
font-family: 'Helvetica';
padding-left: 5px;
padding-top: 5px;
font-size: 1em;
text-transform: uppercase;
letter-spacing: 1.5px;
height: auto;
}
.container
{
display:inline-flex;
background-color: #fff;
vertical-align: top;
margin: auto;
width: 200px;
height: 50px;
}
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<img src="https://user-images.githubusercontent.com/13046668/41792152-165b8206-7682-11e8-8182-dad5d193b494.png" class="img"><!--
--><div class="container">
<div class="overline" style="clear: both">overline</div>
<br>
<div class="content" style="clear: both">superman is back</div>
</div>
</body>
</html>
解决方案
在容器 div 上添加 flex-direction: 列
删除了 br 标签。
两者都不需要清楚
删除了容器标签上的宽度
body {
background-color: darkslategrey;
}
.img {
display: inline-flex;
width: 50;
height: 50;
margin: auto;
}
.overline {
display: inline-block;
vertical-align: top;
font-family: 'Helvetica';
padding-left: 5px;
padding-top: 5px;
font-size: .75em;
text-transform: uppercase;
letter-spacing: 1.5px;
height: auto;
}
.content {
display: inline-block;
vertical-align: bottom;
font-family: 'Helvetica';
padding: 5px 5px 0 5px;
font-size: 1em;
text-transform: uppercase;
letter-spacing: 1.5px;
height: auto;
}
.container {
display: inline-flex;
background-color: #fff;
vertical-align: top;
margin: auto;
height: 50px;
flex-direction: column;
}
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<img src="https://user-images.githubusercontent.com/13046668/41792152-165b8206-7682-11e8-8182-dad5d193b494.png" class="img">
<!--
-->
<div class="container">
<div class="overline">overline</div>
<div class="content">superman is back</div>
</div>
</body>
</html>
推荐阅读
- github - Git 命令从问题编号获取拉取请求主题主体
- time-complexity - 限定大 O 的表达式
- swift - 如何在 Swift 的 UISlider 中移动视图以获得价值?
- jenkins - 传递 JAVA_ARGS 的 Jenkins 掌舵值
- xamarin - 领域数据库语言环境支持
- java - 等到价格完全加载的最佳方式(例如在比较网站上)
- python - 如何在没有基本事实的情况下评估 CBIR 系统?
- javascript - 如何显示这种类型的位模式?
- python - 表单不显示在html,django上
- javascript - 从数组中,生成所有不同的、非空的子数组,并保持顺序