gpt4 book ai didi

html - 在 p 标签内使用 div 会丢失我的样式

转载 作者:太空宇宙 更新时间:2023-11-03 20:31:55 24 4
gpt4 key购买 nike

我有一个页面,我想在其中向学生表示一个 URL(但没有浏览器默认设置,例如在悬停时更改为指针等),并且我通过将文本包装在 div 中而丢失了我的样式。我有

index.html:

<p>
we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
<div style="color:blue;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>

样式.css:

body {
background: #f0f0f0;
width: 80%;
margin: 0 auto;
}

h1 {
text-align: center;
margin-top: 35px;
margin-bottom: 60px;
}

p {
font-size: 20px;
font-family: sans-serif;
}

.cl {
margin: 38px;
padding: 25px;
background: #f8f8f8;
font-family:DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New;
font-size: 12px;
}

.fake-url {
color: blue;
}

最近我尝试在 div 中使用 .fake-url

<p>
we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
<div class="fake-url;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>

然后我做了

p, p div {
font-size: 20px;
font-family: sans-serif;
}

enter image description here

最佳答案

我想建议您使用 span 而不是 div,div 是 block 元素,另一方面 span 是内联元素,更适合您要使用它的上下文。

正如上面提到的,你有一个额外的;在 div 的类中

关于html - 在 p 标签内使用 div 会丢失我的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40276251/

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