是否可以在不影响子元素不透明度的情况下设置背景图像的不透明度?
页脚中的所有链接都需要一个自定义项目符号(背景图像),自定义项目符号的不透明度应为50%.
<div id="footer">
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
#footer ul li {
background: url(/images/arrow.png) no-repeat 0 50%;
}
Run Code Online (Sandbox Code Playgroud)
我尝试将列表项的不透明度设置为50%,但是链接文本的不透明度也是50% - 并且似乎没有办法重置子元素的不透明度:
#footer ul li {
background: url(/images/arrow.png) no-repeat 0 50%;
/* will also set the opacity of the link text */
opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用rgba,但这对背景图片没有任何影响:
#footer ul li {
/* rgba doesn't apply to the background image */
background: rgba(255, 255, 255, …Run Code Online (Sandbox Code Playgroud) 我找到了一种方法,通过设置使div容器占据页面的至少全高min-height: 100%;.但是,当我添加嵌套的div和set时height: 100%;,它不会延伸到容器的高度.有办法解决吗?
html, body {
height: 100%;
margin: 0;
}
#containment {
min-height: 100%;
background: pink;
}
#containment-shadow-left {
height: 100%;
background: aqua;
}Run Code Online (Sandbox Code Playgroud)
<div id="containment">
<div id="containment-shadow-left">
Hello World!
</div>
</div>Run Code Online (Sandbox Code Playgroud)
正如您在下面的演示中所看到的,margin: auto;将蓝色div水平居中,而不是垂直居中.为什么不?
.box {
border: 1px solid red;
width: 100px;
height: 100px;
}
.center {
background: blue;
width: 50px;
height: 50px;
margin: auto;
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
<div class="center"></div>
</div>Run Code Online (Sandbox Code Playgroud)
我的问题不是要求解决方法.
最近,Chrome DevTools已经开始将所有元素的HEX颜色转换为RGB值,无论是在CSS中设置HEX颜色还是通过DevTools本身设置.怎么阻止?
我知道按住Shift+单击将颜色转换为其他格式的颜色图标方法,但我觉得这很不方便.我想知道是否有人知道如何阻止这种情况发生?
我正在开发一个MiniDLNA服务器,通过WiFi流媒体.现有文件正确显示.但是,当我向媒体文件夹添加新文件时,MiniDLNA客户端不会更新更改.我也尝试重新启动服务器,但它没有反映出更改.
我改变了inotify_interval = 60但它还没有更新files.db哪个是MiniDLNA媒体列表数据库.如果我删除此数据库并重新启动服务器,则会显示更改.
有谁知道问题可能是什么?
使用Twitter Bootstrap时,我应该在容器div中嵌套行div并将所有span div放在嵌套行中吗?这是最好的做法吗?
如果我将span div直接放在我的div div中并且不将行div包含在容器div中,该怎么办?
如果我将span div直接放在容器div中,而不使用行div,该怎么办?
我所知道的是一个容器是940px,一行是960px.但是,我已经看到了将div放在容器div中的示例.这会有所帮助还是会让显示器变得混乱?
请解释我要遵循的最佳方法以及在什么情况下.
我有背景颜色应用于<span>标签,也有左右padding设置.问题是:当文本被包裹在几行上时,仅应用于每行padding的左(开始)和右(结束),而<span>不是左(开始)和右(结束).
如何将左右两侧padding应用于中间线?
h1 {
font-weight: 800;
font-size: 5em;
line-height: 1.35em;
margin-bottom: 40px;
color: #fff;
}
h1 span {
background-color: rgba(0, 0, 0, 0.5);
padding: 0 20px;
}Run Code Online (Sandbox Code Playgroud)
<h1><span>The quick brown fox jumps over the lazy dog.</span></h1>Run Code Online (Sandbox Code Playgroud)
这种行为有点奇怪和怪异.如果有一个与它的容器display属性设置为flex与flex-direction对column,对的方向<hr>里面的元素会发生变化,成为垂直和它的高度将降低,以适应该行的高度.
html, body {
height: 100%;
}
body {
font-family: sans-serif;
}
.container {
padding: 20px;
height: 100%;
display: flex;
flex-direction: column;
flex-grow: 1;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<h3>Title</h3>
<hr/>
<div class="content">
<p>This is some content</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
看看这支笔.
Firefox和Chrome已确认此行为.我没有找到任何解释.我该如何解决?