繁体   English   中英

如何在 html 中为我的链接添加背景栏?

[英]How do i add background bar for my links in html?

这是我的代码:

 a:link, a:visited { background-color: white; color: black; border: 2px solid green; padding: 10px 20px; text-align: center; text-decoration: none; display: inline-block; position: center; top: 0%; margin: 0px 0 0 0px; height: auto; width: auto; font-family: cursive; } a:hover, a:active { background-color: green; color: white; }
 <a href="1st_Page.html" target="_blank">1st</a> <a href="2nd_Page.html" target="_blank">2nd</a> <a href="3th_Page.html" target="_blank">3rd</a>

假设您的意思是某种用于放置按钮的容器,请将其包装在 div 中:

 a:link, a:visited { background-color: white; color: black; border: 2px solid green; padding: 10px 20px; text-align: center; text-decoration: none; display: inline-block; position: center; top: 0%; margin: 0px 0 0 0px; height: auto; width: auto; font-family: cursive; } a:hover, a:active { background-color: green; color: white; } .container { background: red; padding: 0.5em; }
 <div class="container"> <a href="1st_Page.html" target="_blank">1st</a> <a href="2nd_Page.html" target="_blank">2nd</a> <a href="3th_Page.html" target="_blank">3rd</a> </div>

您可以将它们包装在 div 中并提供背景

 div { background: blue; padding: 12px; } a:link, a:visited { background-color: white; color: black; border: 2px solid green; padding: 10px 20px; text-align: center; text-decoration: none; display: inline-block; position: center; top: 0%; margin: 0px 0 0 0px; height: auto; width: auto; font-family: cursive; } a:hover, a:active { background-color: green; color: white; }
 <div> <a href="1st_Page.html" target="_blank">1st</a> <a href="2nd_Page.html" target="_blank">2nd</a> <a href="3th_Page.html" target="_blank">3rd</a> </div

暂无
暂无

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

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