html - 图像左侧有额外的空白区域。任何事情都有帮助
问题描述
我无法摆脱的图像左侧有这个不可见的空白区域。我已经尝试了很多东西,甚至是下面的代码。我希望图像能够覆盖整个屏幕,周围没有任何空白。
html, style, body{
margin:0;
padding: 0;
}
而且,如果有人可以提供帮助,仍然没有结果。这将非常有帮助。
<html>
<head>
<style>
<link href="https://fonts.googleapis.com/css?family=Concert+One|Oswald&display=swap" rel="stylesheet">
.container {
position: relative;
text-align: center;
}
/* TEXT SETTINGS*/
.text {
position: absolute ;
top: 15%;
left: 40%;
transform: translate(-30%, -50%);
color: white;
font-size: 100px;
text-size-adjust: auto;
font-family: 'Oswald', sans-serif;
}
.text2 {
position: absolute ;
top: 40%;
left: 10%;
transform: translate(0%, -50%);
color: black;
font-size:90px;
text-size-adjust: auto;
font-family: 'Concert One', cursive;
}
.text3 {
position: absolute ;
top: 70%;
left: 10%;
transform: translate(5%, -50%);
color: white;
font-size: 80px;
text-size-adjust: auto;
font-family: 'Concert One', cursive;
}
html, style, body{
margin:0;
padding: 0;
}
</style>
</head>
<body>
<div class="container" >
<img src="https://images.unsplash.com/photo-1495741738915-f877fcd5f5f7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2550&q=80;" alt="Rocky Mountains"margin="0" padding="0" width="1360px" height="800px">
<div class="text" >TEXT</div>
<div class="text2" ><strong>TEXT</strong></div>
<div class="text3" >TEXT</div>
</div>
</body>
</html>
解决方案
试试这个代码:
body *{
box-sizing:border-box;
}
推荐阅读
- javascript - MongoDB Bulkwrite 查询冻结 Node.js 响应
- pandas - 根据另一个 df 中的特定索引替换一个 df 中的值
- flutter - Flutter:如何防止 BottomNavigationBar 在选项卡更改或推送到其他屏幕时重建?
- reactjs - Axios 发布请求在 React Native 中不起作用
- javascript - 过滤掉递归目录路径
- c# - .Net Core 会话在某些控制器方法上返回 null
- python-3.x - Python:获取两个文件之间的唯一行
- c# - 泛型类不能将类型“T”隐式转换为“Int”
- python - 当神经网络无法映射数据之间的关系时,可能是什么原因?
- hyperledger-fabric - 如何获取历史状态的传递给事务的参数