html - 如何淡化对 CSS 中元素的更改

标签 html css css-transitions

当鼠标悬停在 CSS 元素上时,我试图淡化对元素的编辑。具体来说,将 bordersolid 更改为 dotted,通过淡化更改,我该怎么做?

编辑:

也许我需要更具体地了解这里的上下文是我当前的代码:

li {
  font-family: 'Roboto', sans-serif;
  font-size: 20px;
  color: black;
  border-bottom: 1px solid black;
}

li:hover {
  border-bottom: 1px dotted black;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

最佳答案

Here是一些 CSS 技巧可以产生这种效果。缺点是内部不能透明。

div {
  position: relative;
  width: 50px;
  height: 50px;
  display: block;
  border: 3px dotted red;
  background: red;
  transition: 1s ease-in-out all;
}

div:after {
  position: absolute;
  content: ' ';
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
}

div:hover {
  background: transparent;
}
<div></div>

关于html - 如何淡化对 CSS 中元素的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45489929/

相关文章:

javascript - Angular ngFor不显示更改的数组

html - 在视口(viewport)中居中元素而不是包含 Bootstrap 列

html - CSS3 过渡向下滑动元素

jquery - 如何通过单击而不是悬停来激活交叉淡入淡出?

javascript - 无法让 Vue.js CSS 转换工作?

javascript - 需要有关 insideHTML 和数组输入变量的帮助

javascript - 图像尺寸问题

javascript - Android 默认浏览器 : Google Maps makes "position: relative" elements scroll over the top of the page

html - 在悬停时更改图像和文本并单击

javascript - 有没有办法让 Firefox 和 Chrome 滚动相同的元素?