gpt4 book ai didi

html - 我如何防止 CSS 样式影响我网站的其他部分?

转载 作者:行者123 更新时间:2023-11-28 00:48:56 25 4
gpt4 key购买 nike

我是代码新手,我正在使用 W3schools 慢慢学习,但我仍然需要帮助并且不完全理解某些事情。

<html>
<body style="background-color:#D2563C;">
<a href="">
<img src="C:\Users\Burke\Desktop\hillbilly
\Pictures\bert.png" alt="HTML tutorial"
style="width:725px;height:90px;">
</a>
<style>

a:link, a:visited #tabs{
box-align: center;
border-style: solid;
border-color: white;
border-width: 1px;
background-color: #057A8C;
color: white;
padding: 10px 31px;
text-align: center;
text-decoration: none;
display: inline-block;
list-style-type:none
}


a:hover, a:active #tabs{
background-color: white;
color: #057A8C
}
</style>
</head>
<body>



<div class="center">
<a href="\Desktop\bob\cool.html"
target="_blank">Home</a>
<a href="\Desktop\bob\Contact Us.html"
target="_blank">Contact Us</a>
<a href="Desktop\bob\Printing.html" target="_blank">Printing</a>
<a href="Desktop\bob\Technology.html"
target="_blank">Technology</a>
<a href="Desktop\bob\Printership.html"
target="_blank">Printership</a>
</div>

<script type="text/javascript"
src="https://platform.linkedin.com/badges/js/profile.js" async defer>
</script>


<div class="LI-profile-badge" data-version="v1" data-size="medium" data-
locale="en_US" data-type="vertical" data-theme="dark" data-
vanity="sullivanstrong"><a class="LI-simple-link"
href='https://www.linkedin.com/in/sullivanstrong?trk=profile-
badge'>James T kirk</a></div>





</body>
</html>

这是我的代码

How do I get the blue border off of the title picture but keep it on the tabs? Also, How do i center the Title Picture and Tabs?

点击我如何,查看图片,

最佳答案

您正在将样式应用到元素本身 - 这意味着样式将始终应用。

有几种方法可以解决这个问题,但最好的方法是使用“类”。

类可以添加到任何元素。语法是:

<a href="/example" class="example-class test">Example Link</a>

“类”作为“属性”添加到元素中。使用空格分隔类。上面的示例将有 2 个单独的类。 “示例类”和“测试”。

然后您可以使用类将样式直接应用于元素。类前面有一个“。” (ID 以#

开头

.example-class {
/* styling here */
}

如上添加的任何样式将仅应用于该类。横幅上也出现蓝色边框的原因是因为您直接将样式应用于元素,因此所有“a”元素都将附加样式。

补充一下 - 您发布的代码存在一些基本问题。我建议阅读一些 HTML 和 CSS 的基础知识,并查看结构和格式。 Codeacademy 是一个很好的起点: https://www.codecademy.com/ar/tracks/htmlcss

例子:

<a href="\Desktop\bob\jamespak.html" class="tab-class"
target="_blank">Home</a>

.tab-class {
/*styling*/
}

关于html - 我如何防止 CSS 样式影响我网站的其他部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48603294/

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