gpt4 book ai didi

html - 如何链接到 css 中的 div 并使

具有设定的宽度?

转载 作者:行者123 更新时间:2023-11-27 23:56:02 29 4
gpt4 key购买 nike

我正在尝试将 html 链接到 css,但遇到问题并且卡住了。感谢任何帮助

我尝试过使用 div 类,但我是新手所以不太确定该怎么做

HTML

<!DOCTYPE html>
<html>
<head>
<title>About UnixCast</title>
<link href="about.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="head">
<div class="head">Hi there! I'm Lewis and welcome to UnixCast.com!</div>
<div id="para">
<div id="para1">
<p>If you're reading this I just would like to say a huge thank you for taking the time to want to know who's behind UnixCast. I'm a full-time student with a big passion for learning. I enjoy studying physics and hope to get a degree in astrophysics sometime in the future. I've always had a passion for creating content online. From when YouTube was at the start of its big popularity boom, I fell in love with the idea of sharing content freely for everyone to see. My goals for my content are simple:
<ul style="list-style-type:disc;">
<li>Share my passion and interest with the internet.</li>
<li>Educate my self on topics that I find interesting.</li>
<li>Inspire others to learn about the world around them.</li>
</ul>
</p>
</div>
</div>
<div class="para2">
<p>And that's basically it. If you feel like you'd enjoy my content then feel free to check out what I do by visiting my<a href="https://www.youtube.com/channel/UCPSlslWokRgiA3WEoMeqcFw?"> YouTube</a> and if you enjoy the content please consider subscribing! Have a great day and I hope to see you around!</p>
</div>
</div>
</body>
</html>

CSS

body{
margin: 0px;
padding: 0px;
background-color: #19181D;
}
.head{
font-family: sans-serif;
font-size: 25px;
color: white;
position: relative;
top: 10%;
left: 5%;
transform: translate(-50%, -50%);
}
.para1{
font-family: sans-serif;
font-size: 15px;
color: white;
position: relative;
top: 120px;
left: 5%;
width: 320px;
height: 320px;
margin: 0 auto;
transform: translate(-50%, -50%);
}

预期的结果是让html链接到css

最佳答案

不知道你的HTML和CSS水平,但是你需要把CSS文件调用到你的html中。您使用 .head 来调用您的 class = "head",并使用您的 #head 来调用您的 id="head"。

因为你有 2 个头,我建议使用不同的名称(以避免任何冲突)。 div="head_div"和另一个id="head" -> 类似的东西!

如果你的 css 文件在一个文件夹中(比方说,叫做 CSS),你需要在你的 href 中定义路径(比如 href="./CSS/cssfile.css )

希望对您有所帮助!

编辑:我的错,阅读你的文字并错过了标题 -.-只需在 <p> 中添加一个 ID您要更改的标签,然后在 CSS 中发挥您的魔力(设置您想要的宽度) <p id ="something"></p>CSS: #something{
css here;
}

关于html - 如何链接到 css 中的 div 并使 <p> 具有设定的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56265435/

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