gpt4 book ai didi

html - 防止 float right 断线

转载 作者:行者123 更新时间:2023-11-27 23:00:25 34 4
gpt4 key购买 nike

我正在尝试制作一个 html + css 网站,我试图为一个跨度(具有 .float 类)制作一个正确的 float ,但它打破了一条线,我想知道如何防止它打破一个线?我尝试了 display:inline-block 但没有添加,完整代码:

<html>

<head>
<title> Web page </title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">



</head>
<body>
<!-- Navbar -->
<nav>
<a href="">Acceuil</a> <span> | </span>
<a href="">Types d'appareils</a> <span> | </span>
<a href="">Ordinateurs</a> <span> | </span>
<a href="">Telephones</a> <span> | </span>
<a href="">O.S</a> <span> | </span>
<a href="">Etudes</a>

<a href="https://twitter.com/BadisKerdellou" class="fa fa-twitter fa-2x"></a>
<a href="https://www.instagram.com/badis_kerdellou/?hl=fr" class="fa fa-instagram fa-2x"></a>
<a href="https://www.facebook.com/profile.php?id=100041024162109" class="fa fa-facebook fa-2x"></a>

</nav>
<!-- End of Navbar -->

<div class="header">
<br> <br>
<span class="pad"> Soufferez vous </span> <br> <br>
<span class="pad"> De l'utlisation </span>
<span class="not"> exagirée </span><span class="notn">de l'internet? </span>
<br> <br> <br> <br>
<img src="hey2.png">

<span class="float"> Hey </span>


</div>


</body>
</html>

CSS 代码:

body{
margin: 0;
padding: 0;
font-family: 'Raleway', sans-serif;
}
nav{
background-color: purple;
height: 55px;
padding-top: 25px;
padding-right: 20px;
border-bottom: 5px solid gray
}

nav a{
display: inline-block; /*added*/

text-decoration: none;
color:white;
font-size: 20px;
margin-left: 10px

}

nav span{
color: white;
font-size: 15px
}

.fa{
float: right;
}

.header{
background-color: purple;
height: 600px
}

h1{
padding: 0;
margin: 0
}

.header h2,h1{
display: inline-block;
color: white;
font-family: 'Raleway', sans-serif;
margin-left: 20px


}

.pad{
color: wheat;
padding-left: 15px;
font-size: 40px
}

.not{
color: red;
padding: 0;
font-size: 40px
}

.notn{
color: wheat;
font-size: 40px
}

.header img{
height: 300px
}

.float{
float: right
}

.header span{
display: inline
}

codepen.io:

https://codepen.io/badis-kerdellou/pen/NWWVpLV

最佳答案

我不确定我是不是笨到连问题都没有发现,但很明显 <br>断线,只需输入 <span class="float"> Hey </span><br> 之前,像这样:

<div class="header"> 

<br> <br>
<span class="pad"> Soufferez vous </span> <br> <br>
<span class="pad"> De l'utlisation </span>
<span class="not"> exagirée </span><span class="notn">de l'internet? </span>
<span class="float"> Hey </span> <!--Just moved it above the <br>-->
<br> <br> <br> <br>
<img src="hey2.png">

关于html - 防止 float right 断线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59021906/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com