html - 一个元素在另一个元素之上,但居中,具有文本缩放和固定宽度和高度?
问题描述
如何将一个元素放在另一个元素之上,但仍然具有固定大小?我试过这个,但它不限制宽度和中心文本。当有很多符号时,文本会超出边界。
另外,如何根据容器的宽度缩放文本?
html {
background-color: gray;
color: white;
}
.alarm {
position: relative;
float: right;
width: 369;
height: 123;
padding: 5%;
}
.message {
margin: 5px;
word-break: break-all;
background-color: black;
text-align: center; /* doesn't work */
/* font scaling depending on the number of characters..? */
}
.message-container {
max-width: 246px;
max-height: 123px; /* doesn't work */
position: absolute;
}
.video {
background-color: yellow;
width: 369px;
height: 123px;
}
<div class="alarm">
<div class="message-container">
<div class="message">
{name} is now following! fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
</div>
</div>
<div class="video-container">
<!--there must have been a video-->
<div class="video"></div>
</div>
</div>
解决方案
推荐阅读
- fonts - 在 Rmarkdown pdf 中更改 Kable 的字体
- c++ - CATCH_CONFIG_MAIN 的 gtest 等价物是什么?
- c# - 来自多个表格的图表
- javascript - Ember 每个循环在数组更新时重新渲染整个对象数组
- python - opencv中轮廓的共享边界
- angular - 找不到名称“数学”
- android - 我们可以将一个数据库用于两个或多个应用程序吗
- unity3d - 什么是 l 和 v1 以及它持有什么类型的值?
- numpy - 查找除for循环以外的批处理数据中第一次出现数字的索引的有效方法
- android - 在意图中获取 SharedPreferences