italic - 如何将不同的样式添加到 HTML 中一行的不同部分并将所有内容一起打印?
问题描述
我想将不同的样式添加到 HTML 中一行的不同部分,然后一起打印该行。想象一下我有下一行:
你好,我的名字是 Bogdan,我住在西班牙。
我设法为该行添加了不同的样式,但我无法将所有部分放在一起,并对每个部分应用不同的样式。
<!DOCTYPE html>
<html>
<head>
<style>
<style>
div{
}.bold{ font-weight: bold;
}
.normal{ font-weight: normal;
}
.italic{
font-style: italic;
}
.left{
text-align:left;
float:left;
}
.container{
letter-spacing:-1px;
width: 372px;
font-family: Monaco,monospace;
font-size:19px;}
.center{
text-align:center;
}
.underline{
text-decoration: underline;
}
.doubleFont{font-size:38px;}
</style>
</head>
<body>
<div class = container>
<div class=>
<div class=>Hello my name is Bogdan</div>
</div>
<div class="underline bold">
<div class=>and i live </div>
</div>
<div class="bold">
<div class=>in Spain</div>
</div>
<br>
</div>
</body>
</html>
解决方案
用这样的跨度替换 div:
<span>Hello my name is Bogdan</span>
<span class="underline bold">and i live </span>
<span class="bold">in Spain</span>
跨度是内联元素,并在一行上换行。除非另有设置,否则 Div 总是在下一行。还可以考虑在 .container 类上设置更大的宽度。
推荐阅读
- windows - 如何让“使用 pyinstaller 构建 python 应用程序”工作?
- java - SQL 错误:0,SQLState:空 HikariPool-1 - 连接不可用,请求在 30000 毫秒后超时
- kubernetes - 如何使用默认 Ingress 使用 Kubernetes microk8s 设置 Letsencrypt?
- python - 如何更改代码以便在重新启动后它可以工作并且在终端中可见?
- mysql - docker mysql local-inline db设置问题
- fiddler - 如何在 Android TV 上安装证书?
- python - 我通常在“pyrcc5”中遇到问题,无法识别为内部或外部命令、可运行程序或批处理文件
- python - 有没有办法显示networkx中节点和边缘之间的连接数
- prestashop-1.7 - Prestashop 中的任何想法 是什么意思?
- optimization - Mosek求解器中决策变量值的初始化(通过Cvxpy框架)