html - 对于 CSS,我如何定位此 Div 中的特定 P
问题描述
我正在尝试在以下代码中定位 ap 。我想编写一个类来将文本阴影添加到该 p 的文本中。
我只是不知道要定位哪个类,以及正确的语法是什么。我以为是 .mainbg p { xxxxxx } 但这不起作用。
<section aria-label="home" class="mainbg" id="home">
<!-- intro -->
<div class="container">
<div class="row">
<div class="overlay-main v-align">
<div class="col-md-10 col-xs-11">
<h1 class="onStep" data-animation="animbouncefall" data-time="300">LOUIS WALLACE CONSTRUCTION</h1>
<div
class="onStep"
data-animation="fadeInUp"
data-time="600"
id="slidertext"
style=" text-shadow: 2px 1px 4px black;"
>
<h3 class="main-text">Oroville General Contractor</h3>
<h3 class="main-text">Over A Decade Of Experience</h3>
<h3 class="main-text">All Phases Of Construction</h3>
</div>
<p
class="onStep"
data-animation="animbouncefall"
data-time="900"
style="font-weight:500"
style="text-shadow:20px 20px 20px black;"
>
No matter how large or small the project, we ensure that your project is completed with precision and
professionalism. We take pride in our quality craftsmanship, our attention to detail, and our open line of
communication with each and every customer. With each project, we understand that our role is about more
than simply putting up walls — it’s about ensuring that your vision is turned into a reality.
</p>
</div>
</div>
</div>
</div>
</section>
解决方案
首先,css
你的标签上有两个内联样式p
,所以只有第一个会生效:
<p class="onStep" ... style="font-weight:500" style="text-shadow:20px 20px 20px black;">...</p>
它应该是:
<p class="onStep" ... style="font-weight:500; text-shadow:20px 20px 20px black;">...</p>
选择.mainbg p
器应该可以正常工作,请记住,如果您有内联css
,它将覆盖您的.mainbg p
选择器。
在这种情况下尽量不要使用内联 css。
.mainbg p {
font-weight:500;
text-shadow:20px 20px 20px black;
}
<section aria-label="home" class="mainbg" id="home">
<!-- intro -->
<div class="container">
<div class="row">
<div class="overlay-main v-align">
<div class="col-md-10 col-xs-11">
<h1 class="onStep" data-animation="animbouncefall" data-time="300">LOUIS WALLACE CONSTRUCTION</h1>
<div class="onStep" data-animation="fadeInUp" data-time="600" id="slidertext" style=" text-shadow: 2px 1px 4px black;">
<h3 class="main-text">Oroville General Contractor</h3>
<h3 class="main-text">Over A Decade Of Experience</h3>
<h3 class="main-text">All Phases Of Construction</h3>
</div>
<p class="onStep" data-animation="animbouncefall" data-time="900">No matter how large or small the project, we ensure that your project is completed with precision and professionalism. We take pride in our quality craftsmanship, our attention to detail, and our open line of communication with each and every customer. With each project, we understand that our role is about more than simply putting up walls — it’s about ensuring that your vision is turned into a reality.
</div>
</div>
</div>
</div>
推荐阅读
- vba - 从父表单上的文本框条目中过滤子表单数据
- sql - 内连接查询返回不同的值
- windows - pyttsx - 郎集
- ios - SwiftUI 视图大小(父/子关系)
- javascript - 如何为 React Native 组件预处理获取的 redux 数据?
- wpf - 如何以编程方式使用 ModernWPF
- reactjs - 在 React Native 中将函数传递给功能组件
- javascript - 使用来自服务器的数据自动提供 html 页面?
- bash - 用于检查 openshift/kubernetes pod 是否准备就绪的 Bash 脚本
- c# - 为什么我在 C# 中拒绝 COM 端口访问