html - Float 将所有内容移到一侧,HTML 和 CSS
问题描述
我对图像和“浮动:对;”有疑问。它移动图像上的所有内容。我真的需要帮助。我只是一个初学者。任何帮助将不胜感激。请帮我。我的 HTML 代码:
<section id="header">
<div class="container">
<img scr="./img/logo.png" class="logo">
<div class="header-text">
<h1>Choose the cheapest teachers</h1>
<span class="square"></span>
<p>Here you can find the best people<br>Start working for us right now</p>
<button class="common-btn">Read more</button>
</div>
</div>
我的 CSS 代码:
* {
margin: 0;
padding: 0;
font-family: sans-serif;
font: Nunito;
}
#header {
height: 100vh;
background-image: url(img/image3.png);
background-position: center;
background-size: cover;
width: 80vh;
height: 80vh;
padding:35px;
float: right;
}
}
.conatiner {
margin-right: 100px;
margin-left: 100px;
}
.logo {
margin-top: 30px;
width: 100px;
}
.header-text{
max-width: 350px;
margin-top: 140px;
}
解决方案
* {
margin: 0;
padding: 0;
font-family: sans-serif;
font: Nunito;
}
#header {
height: 100vh;
background-image: url(img/image3.png);
background-position: center;
background-size: cover;
width: 80%;
height: 80vh;
padding:35px;
}
img.logo{
float: right!important;
}
.container {
margin:0;
width:100%;
}
.logo {
margin-top: 30px;
width: 100px;
}
.header-text{
max-width: 350px;
margin-top: 140px;
}
<section id="header">
<div class="container">
<img src="https://placekitten.com/200/200" class="logo">
<div class="header-text">
<h1>Choose the cheapest teachers</h1>
<span class="square"></span>
<p>Here you can find the best people<br>Start working for us right now</p>
<button class="common-btn">Read more</button>
</div>
</div>
</section>
推荐阅读
- java - 如何在输出中添加行号并检测是否找不到文件?
- reactjs - 使用 ReactJs 从 API 获取数据,但得到完全空白的页面,没有错误
- python - 为什么我的变量即使加了 1 也没有改变?
- python - Python pandas 将带有数组内容的数据帧附加到 hdf 文件
- python - 使用 Selenium 在下拉按钮中通过正则表达式选择值
- mysql - 如何获取与父表 id 相关的所有孙子
- flutter - 如何跳转到 PageView 中的特定页面?
- amazon-web-services - 使用 CodeDeploy 使用 AppSpec 或脚本设置权限
- css - CSS - 使所有图像都有一个圆形边框
- mysql - MySQL 基于 ID 和 Week 的分区