如何在 anchor 标签的背景图像周围设置和调整边框? 现在我有了我的 anchor 标签的边框,因为宽度和高度是预定义的。我可以在这些 anchor 标记的背景图像周围添加边框,即“Next”和“Prev”吗??
<!DOCTYPE html>
<html>
<head>
<title>jQuery UI Dialog: Hide the Close Button/Title Bar</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<style type="text/css">
.mySlider
{
//
}
.shadow_div
{
//
}
.mySlider img
{
width:800px;
height:480px;
display:none;
}
.Parent_Slider > a
{
text-decoration:none;
font-weight:bold;
width:32px;
height:32px;
position:absolute;
top:45%;
text-indent:-9999px;
}
.Next_Class
{
right:282px;
background-image:url(Images/rightarrow.jpg);
border:1px solid white;
}
.Prev_Class
{
left:282px;
background-image:url(Images/leftarrow.jpg);
}
ul.Round_Buttons
{
position:relative;
left:35%;
top:5px;
text-decoration:none;
list-style-type:none;
text-indent:-9999px
}
ul.Round_Buttons li
{
float:left;
background-color:white;
margin:1px 5px;
padding:0px 7px;
border-radius:50%;
border-width:1px;
border:1px solid #3610a5;
cursor:pointer;
box-shadow:1px -1px 3px 1px #3610a5;
transition:all 1s ease-in-out;
-moz-transition:all 1s ease-in-out;
-webkit-transition:all 1s ease-in-out;
}
ul.Round_Buttons li:hover
{
transform:rotate(-360deg);
-webkit-transform:rotate(-360deg);
-moz-transform:rotate(-360deg);
}
</style>
<script type="text/javascript">
$(document).ready(function () {
//
});
</script>
</head>
<body>
<div class="Parent_Slider">
<div id="my_image_slider" class="mySlider">
<img id="1" src="Images/bmw.jpg" alt="" title="Audi India"/>
<img id="2" src="Images/audi.jpg" alt="" title="BMW India" />
<img id="3" src="Images/aston-martin.jpg" alt="" title="Aston-Martin APAC" />
<img id="4" src="Images/bugatti.jpg" alt="" title="Buggatti APAC" />
<img id="5" src="Images/koenigsegg.jpg" alt="" title="Koenigsegg APAC" />
</div>
<a href="#" class="Next_Class">Next</a>
<a href="#" class="Prev_Class">Prev</a>
</div>
<div class="shadow_div" >
<ul class="Round_Buttons">
<li id="1st_Round"><a href="#">1</a></li>
<li id="2nd_Round"><a href="#">2</a></li>
<li id="3rd_Round"><a href="#">3</a></li>
<li id="4th_Round"><a href="#">4</a></li>
<li id="5th_Round"><a href="#">5</a></li>
</ul>
</div>
最佳答案
您不能使用 css 为背景图像添加边框,但可能有一些替代方法。没有更多细节,很难说出最佳路线,但假设您知道图像的尺寸,您可以只设置 <a>
的边框。标记并使其宽度/高度与图像匹配:
a {
background:url(http://www.vision-call.co.uk/images/stories/events/sample.jpg);
border:3px solid red;
display:block;
height:315px; /*height of image*/
width:420px; /*width of image*/
}
更新 根据您对代码的更新问题,我做了另一个 fiddle :
同样的想法。请注意 <a>
的尺寸与图像的尺寸匹配,边框应用于 <a>
, 给人的印象是背景图片有边框。显然,我使用的图像只是样本,看起来不太好,但这种技术应该适合你。
关于html - 如何为 anchor 标签的背景图片添加边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23558122/