- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个红色背景颜色的名字和姓氏,我希望红色在左侧和右侧淡出(大约在红色背景的 2/10 和 8/10),使用 css。
欢迎任何帮助
body {
margin: 0;
padding: 0;
color: white;
text-align: center;
background-image:
url(https://www.abercrombiekent.com/-/media/ak/media-for-prod/journeys/lsgj/asia-classic-japan-mt-fuji-cherry-blossom-mh.jpg?h=500&w=1224&la=en&hash=FE20C6C6D4D6D693DD79CAA29352D7F9825D6804)
}
.name{
background-color: rgba(255,0,0,0.8);
}
.img{
background-size: cover;
background-position: center;
width: 100%;
background-attachment: fixed;
align-items: center;
}
h1{
margin-top: -10px;
font-size: 80px;
letter-spacing: 8px;
font-family: Arial;
}
h2{
margin-top: -60px;
padding-bottom: 20px;
font-size: 31px;
letter-spacing: 5px;
font-family: Arial;
}
<div class= "img">
<div class= "name">
<h1>/////</h1>
<h2>///////////</h2>
</div></div>
最佳答案
可以使用background: linear-gradient
设置背景渐变。您可以使用百分比表示位置和 rgba 颜色(允许您修改不透明度)来设置任意数量的停止点。
我把你的背景颜色改成了这个渐变:
background: linear-gradient(to right, rgba(255, 0, 0, 0) 10%, rgba(255, 0, 0, 1) 20%, rgba(255, 0, 0, 1) 80%, rgba(255, 0, 0, 0) 90%);
body {
margin: 0;
padding: 0;
color: white;
text-align: center;
background-image: url(https://www.abercrombiekent.com/-/media/ak/media-for-prod/journeys/lsgj/asia-classic-japan-mt-fuji-cherry-blossom-mh.jpg?h=500&w=1224&la=en&hash=FE20C6C6D4D6D693DD79CAA29352D7F9825D6804)
}
.name {
background: linear-gradient(to right, rgba(255, 0, 0, 0) 10%, rgba(255, 0, 0, 1) 20%, rgba(255, 0, 0, 1) 80%, rgba(255, 0, 0, 0) 90%);
}
.img {
background-size: cover;
background-position: center;
width: 100%;
background-attachment: fixed;
align-items: center;
}
h1 {
margin-top: -10px;
font-size: 80px;
letter-spacing: 8px;
font-family: Arial;
}
h2 {
margin-top: -60px;
padding-bottom: 20px;
font-size: 31px;
letter-spacing: 5px;
font-family: Arial;
}
<div class="img">
<div class="name">
<h1>/////</h1>
<h2>///////////</h2>
</div>
</div>
关于html - 两侧背景淡出(纯html),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49741430/
我设法检查一个整数是否是从右到左排序的,但我如何检查从左到右的顺序?也许我应该做 2 个功能,一个从左到右检查,另一个从右到左检查?例如,我将 return 0; 替换为第二个函数,该函数检查它是否从
我想在两侧“剪切”我的页面,如下所示: http://i.stack.imgur.com/ngZrp.jpg 演示:https://jsfiddle.net/r2g0eyxf/3/ #left {
我很难在页面的两边都获得背景: 风格 .left { background: url(wax.png); width: 15%; position: absolute; lef
我需要逐步证明:7 + O(n) = O(n) 当两边都有大O的时候,我不知道该怎么做。 我想我理解大 O 符号的概念,但为什么两边都有大 O? 最佳答案 这种表示法的使用不符合大 O 表示法的正式定
我的目标是使 slider 宽度为 1280 像素并位于页面中央。我希望内容的边缘在两侧都有隐藏的溢出。例如,我希望内容的中心始终位于页面的中心,随着浏览器的大小调整,每一边都被切断,并且没有出现水平
我在做什么:在悬停按钮时,我添加了一个 5px 的底部边框。 JS fiddle : http://jsfiddle.net/mUCNB/ 问题: 问题是边框底部在左侧和右侧都延伸了 1px。 问题:
我是一名优秀的程序员,十分优秀!