gpt4 book ai didi

css - h2 跨度之间的虚线

转载 作者:太空宇宙 更新时间:2023-11-03 20:58:10 26 4
gpt4 key购买 nike

我一直在尝试在我的网站上添加一些虚线。
我开始理解这个想法,但我遇到了另一个问题......
我正在制作另一条虚线,这次是在文本和图像之间。这个有点不同。

我也遇到了一些问题,有时由于宽度的变化图像会出现在线条下面:当我更新我的网站时,等等。

我怎样才能把虚线的宽度改成h2的总宽度?
我希望虚线不会打扰任何东西,只是顺利穿过它。

这是我正在使用的代码,我需要在基本原则中保持它:

      <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){

$('.serviceDesc').hide();
$('.serviceName:first').addClass('active').next().show();

$('.serviceName').click(function(){
if( $(this).next().is(':hidden') ) {
$('.serviceName').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
}
return false;
});

});
</script>
<style>
#servicesContainer {
width: 485px;
height: 400px;
margin: 0 auto;
margin-top: 20px;
}
h2.serviceName {
margin: 0;
margin-bottom: 5px;
margin-top: 5px;
background-image: url(http://i.imgur.com/IcnZl.png);
background-position: right top;
background-repeat:no-repeat;
height: 29px;
line-height: 24px;
width: 480px;
font-size: 18px;
font-weight: bold;
float: left;
color:#000;
}
h2.serviceName a {
color: #000;
text-decoration: none;
display: block;
}
h2.active {
background-position: right bottom;
}
.serviceDesc {
margin: 0 0 10px;
padding: 0;
overflow: hidden;
width: 480px;
clear: both;
}
.serviceDesc .block {
}
.serviceDesc .block p {
color: #413f44;
margin: 0;
font-size:18px;
}
</style>

<div id="servicesContainer">
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud. </p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.<br />
<br />
</p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud. </p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................<br />
</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud. </p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
</div>
</div>
<h2 class="serviceName"><a href="#">Text...............................................................................</a></h2>
<div class="serviceDesc">
<div class="block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
</div>
</div>
</div>

http://jsfiddle.net/K7MHK/

最佳答案

phone/email question 一样,都是一样的道理。您可以在元素上使用背景图像来创建虚线。由于您已经了解了 <h2> 的背景知识,将其添加到 <a> :

h2.serviceName a {
background: url(dots.gif) repeat-x bottom left;
/* Other CSS styles */
}

这是 an example .作为奖励,这意味着您也可以摆脱所有硬编码点。

更新:如果你想屏蔽单词后面的点,添加一个 <span>具有环绕文本的纯色背景的元素:

HTML

<h2>
<a href="">
<span>Juicy text</span>
</a>
</h2>

CSS

a span {
background-color: #fff;
}

这将防止 <a> 的虚线背景从显示通过。

关于css - h2 跨度之间的虚线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7591006/

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