gpt4 book ai didi

jquery - 如何只为背景指定类名?

转载 作者:行者123 更新时间:2023-12-01 06:53:08 26 4
gpt4 key购买 nike

我的背景图片有width:118px ,点击背景图像时我想执行一些jquery,我无法使用<a>标签。如何制作cursor:pointer仅在 background以及如何仅为背景指定类名?是否可以?怎么办?

<div id="post1_img"></div>

#post1_img
{
width:280px;
height:33px;
background:url(../images/assets/pullTab-readMore-off-.png) no-repeat top center;
clear:both;
}

编辑

enter image description here

点击“阅读更多”我想执行一些操作,是否可以在不创建任何额外 div 的情况下完成

width of div:280px;

width of image:118px;

http://jsfiddle.net/prash/A8FWa/

最佳答案

嘿,现在习惯了 css 中的 after 属性

<div id="post1_img"></div>

CSS

 #post1_img
{
width:280px;
height:33px;
background:url(http://www.gravatar.com/avatar/9932debdde3decc7726b508f43d57438?s=32&d=identicon&r=PG) no-repeat top center;
clear:both;
border:1px solid black;
position:relative;
}


#post1_img:after{
content:'';
position:absolute;
top:0;
left:50%;
margin-left:-16px;
width:32px;
height:33px;
cursor:pointer;
}

Live demo

关于jquery - 如何只为背景指定类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11755948/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com