将鼠标悬停在容器上时尝试更改文本颜色

发布于 2025-01-10 22:29:41 字数 1682 浏览 4 评论 0原文

我正在尝试在 Divi 博客中设置阅读更多按钮的样式:

https://ourspirit .tempurl.host/whats-happening-across-bc/

客户端希望按钮倾斜,因此我将阅读更多锚点包裹在两个 div 中:

<script type="text/javascript">
jQuery(function($){
    $( ".more-link" ).wrap( "<div class='blog-button-text'></div>" );
    $( ".blog-button-text" ).wrap( "<div class='blog-button-background'></div>" );
});
    
</script>

然后我对 div 进行了样式设置以倾斜背景,然后将文本倾斜回到正常状态:

.blog-button-background {
    
    height:45px;
    width:154px;
    display:flex;
    align-items:center;
    -ms-transform: skewX(-20deg);
  -webkit-transform: skewX(-20deg);
  transform: skewX(-20deg);
    border: 1px solid #b71d23;
    position: relative;
  transition: all .35s;
    display:flex;
    align-items:center;
    justify-content:center;
    

}

.blog-button-text {
    -ms-transform: skewX(20deg);
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
 z-index:2;
    
}

然后他们想要在我添加的按钮上有滚动效果,如下所示:

.blog-button-background:after{
  position: absolute;
    background: rgb(183, 29, 35);
  content: "";
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  transition: all .35s;
    z-index:1;
}

.blog-button-background:hover:after{
  width: 100%;
}

现在我试图做到这一点,以便当我添加时,“阅读更多”按钮上的文本变为白色将鼠标悬停在背景上。不只是在文字上。目前,如果您将鼠标悬停在文本上,它会变为白色(将鼠标悬停在 Divi 菜单中按钮上的设置),但如果我将鼠标悬停在背景上,文本将不可见,因为它仍然与背景颜色相同。

我已经尝试过:

.blog-button-background:hover .blog-button-text a {
    color:white !important;
}

但这没有任何作用。有什么想法吗?

I am trying to style read more buttons in a Divi blog here:

https://ourspirit.tempurl.host/whats-happening-across-b-c/

The client wants the buttons to be skewed, so I wrapped the read more anchor in two divs:

<script type="text/javascript">
jQuery(function($){
    $( ".more-link" ).wrap( "<div class='blog-button-text'></div>" );
    $( ".blog-button-text" ).wrap( "<div class='blog-button-background'></div>" );
});
    
</script>

Then I styled the divs to skew the background, and then skew the text back to normal:

.blog-button-background {
    
    height:45px;
    width:154px;
    display:flex;
    align-items:center;
    -ms-transform: skewX(-20deg);
  -webkit-transform: skewX(-20deg);
  transform: skewX(-20deg);
    border: 1px solid #b71d23;
    position: relative;
  transition: all .35s;
    display:flex;
    align-items:center;
    justify-content:center;
    

}

.blog-button-text {
    -ms-transform: skewX(20deg);
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
 z-index:2;
    
}

They then wanted a scrolling effect on the buttons which I added like so:

.blog-button-background:after{
  position: absolute;
    background: rgb(183, 29, 35);
  content: "";
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  transition: all .35s;
    z-index:1;
}

.blog-button-background:hover:after{
  width: 100%;
}

Now I'm trying to make it so that the text on the button 'Read More' changes to white when I hover over the background. Not just over the text. At the moment if you hover over the text it changes to white (hover settings on button in Divi menus), but if I hover over the background the text is invisible as it is still the same color as the background.

I have tried this:

.blog-button-background:hover .blog-button-text a {
    color:white !important;
}

But this does nothing. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻许诺言 2025-01-17 22:29:41

选择父类到父类来覆盖CSS。

body div.post-content .blog-button-background:hover .blog-button-text a {
    color: white!important;
}

Select parent to parent class for overwrite the css.

body div.post-content .blog-button-background:hover .blog-button-text a {
    color: white!important;
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文