html - 无法通过 SCSS/SASS 在 HTML CSS 中使用文本中心对齐
问题描述
如果您在 codepen https://codepen.io/gladwin-james/pen/NWbrGWm中看到代码,我能够将最后一行 Almonds 居中对齐,但我在浏览器中使用了准确的代码,我无法将杏仁在我的浏览器中居中。杏仁需要在中心,但不是。我还分享了图片下方的确切代码
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap');
body {
background: #e1e1e2;
margin: 0px;
margin-top: -15px;
}
.navbar1 {
color: #fff;
font-family: 'Poppins';
text-align: center;
background: #292727;
// box-shadow: 0 10px 6px -6px #777;
}
.phone_favicon {
width: 14px;
}
.navbar2 {
margin-top: -15px;
color: #fff;
font-family: 'Poppins';
text-align: center;
background: #ffffff;
// box-shadow: 0 10px 6px -6px #777;
padding: 5px;
// border-radius: 8px
}
.the_line {
color: black;
}
// Products //
.our_products_are_nuts {
text-align: center;
font-size: 25px;
font-family: 'Poppins';
}
.nuts_expl {
text-align: center;
font-family: 'Poppins';
margin-top: -15px;
}
.nuts1 {
text-align: center;
font-family: 'Poppins';
margin-top: -15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/main.css">
<title>Document</title>
</head>
<body>
<div class="navbar1">
<div class="container">
<p> For Orders <img class="phone_favicon" src="images/phone.svg" alt="favicon-phoneicon"> +91 - 7299488343 / +91 - 7401429828</p>
</div>
</div>
<div class="navbar2">
<div class="container">
<p> <a href="#">Products</a>
<span class="the_line"> | </span>
<a href="#">Services</a>
<span class="the_line"> | </span>
<a href="#">About Nuts</a>
<span class="the_line"> | </span>
<a href="#">Contact Us</a>
</p>
</div>
</div>
<!--//////////-->
<div class="products">
<p class="our_products_are_nuts">Our Products Are Nuts & Spice</p>
<p class="nuts_expl">Call us to get Nuts and Spices at a best quality <br> and also at a best price</p>
</div>
<div class="pimary_products">
<p class="nuts1">Almonds</p>
</div>
</body>
</html>
我很困惑不知道该怎么办。请帮忙。帮我把那个螺母对准中心。
是的,我在执行之前也保存了程序,
解决方案
只需将 替换// comment
为/* comment */
。
.navbar2 {
margin-top: -15px;
color: #fff;
font-family: 'Poppins';
text-align: center;
background: #ffffff;
/*box-shadow: 0 10px 6px -6px #777;*/
padding: 5px;
/*border-radius: 8px*/
}
.the_line {
color: black;
}
/*Products*/
.our_products_are_nuts {
text-align: center;
font-size: 25px;
font-family: 'Poppins';
}
.nuts_expl {
text-align: center;
font-family: 'Poppins';
margin-top: -15px;
}
.nuts1 {
text-align: center;
font-family: 'Poppins';
margin-top: -15px;
}
推荐阅读
- python - 带有 new_values 的 Forloop
- ruby - 如何在Ruby中以不同的编码保存文件
- database - 如何在 laravel 中建立用户与用户的关系?
- python - Python中封装方法代码的输出混淆
- mysql - 为什么我的函数在 MySQL 中没有按预期工作?
- c# - ASP .Net Core – 多态 DTO
- firebase - 将用户数据保存在 Firebase Firestore 中的最佳实践?
- javascript - 如何测量反应虚拟化表中的单元格大小
- c++ - 用 fstream 写文件在 C++ 中不起作用
- c# - C#将承载令牌传递给生成的代理类以添加标头