简体   繁体   English

添加图像并悬停图像文本

[英]Add image and hover the text of the image

How to Add Transparency when Mouse hover a image and only text of that image get highlighted. 当鼠标悬停在图像上且仅该图像的文本突出显示时,如何添加透明度。 here is my code what is to edited or modified. 这是我的代码要编辑或修改的内容。

thank you in advance. 先感谢您。 Any of code change are welcome and other way to implement this thing is also welcome. 欢迎进行任何代码更改,也欢迎采用其他方式实现此功能。

a {
    color: #355f7c;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

div.body p, div.body dd, div.body li {
    text-align: justify;
    line-height: 130%;
}

div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
    font-family: 'Trebuchet MS', sans-serif;
    background-color: #f2f2f2;
    font-weight: normal;
    color: #20435c;
    border-bottom: 1px solid #ccc;
    margin: 20px -20px 10px -20px;
    padding: 3px 0 3px 10px;
}

div.body h1 { margin-top: 0; font-size: 200%; }
div.body h2 { font-size: 160%; }
div.body h3 { font-size: 140%; }
div.body h4 { font-size: 120%; }
div.body h5 { font-size: 110%; }
div.body h6 { font-size: 100%; }

a.headerlink {
    color: #c60f0f;
    font-size: 0.8em;
    padding: 0 4px 0 4px;
    text-decoration: none;
}

You don't have any image elements in your css (img) 您的CSS中没有任何图像元素(img)

Here is a CSS example for an opacity decrease while hovering over an element: 这是一个CSS示例,用于将鼠标悬停在元素上时降低不透明度:

img{
opacity: 1;
}

img:hover{
opacity: 0.2;
}

Sample code. 样例代码。

 img{
    opacity: 3.0;
    }

img:hover{
opacity: 1.2;
}

You can use something like this. 您可以使用类似这样的东西。 Image & text contained in link and when the link get hovered the image get low highlighted and the text be normal. 链接中包含的图像和文本,以及当链接悬停时,图像的突出显示位置偏低,并且文本正常。 And you can use position: absolute of you want the text to place somewhere in image. 您可以使用position: absolute您希望文本放置在图像中的某个位置。

 <a href="#">
        <img src="" alt="">
        <span>Text</span>
 </a>

the css 的CSS

a {
    display: block;
}
a:hover img {
    opacity: 0.2;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM