search
HomeWeb Front-endHTML Tutorial【CSS写法】超链接样式_html/css_WEB-ITnose

css a; 超链接

我们一般情况下写超链接时会用到,但是现在有个问题。描述如下:
1.当的中间是文字时,带下划线显示。
2.当的之间是图片时,不带下划线显示。

现在想通过CSS式样控制一下,大牛们有没有什么好的方法。

回复讨论(解决方案)

a{ text-decoration:underline;}

当中间是文字会有下划线,为图片时没有

我看着这意思是,想要在都没有下划线或者都有下划线的意思吧?

都不出下划线的情况:
设置:
text-decoration:none;

都有下划线的情况:
这个得用border进行模拟了;
设置:
text-decoration:none;
border-bottom:1px soldi #000;
padding-bottom:2px;//为了border的显示更清晰。

试试看,颜色,border的样式(也可以用图片的哦),padding的大小,都可以更改的。

我看着这意思是,想要在都没有下划线或者都有下划线的意思吧?

都不出下划线的情况:
设置:
text-decoration:none;

都有下划线的情况:
这个得用border进行模拟了;
设置:
text-decoration:none;
border-bottom:1px soldi #000;
padding-bottom:2px;//为了border的显示更清晰。

试试看,颜色,border的样式(也可以用图片的哦),padding的大小,都可以更改的。
谢谢回复,差不多是这个意思。你的这个方法我也试过了。正因为这样,中间如果是图片的时候,也是显示出来的。我现在是想如果是文字的时候,下划线显示。如果是图片的时候,下划线不显示。

我觉得如果是文字的话里面可以在链接里面加一个span了,然后控制span的css。可以设置为:text-decoration:underline;图像的话就用
text-decoration:none;
border-bottom:1px soldi #000;
padding-bottom:2px;

我晕,我试了下不会出现你说的情况啊

不做处理,图片都没有下划线的。

我刚看了下W3C对text-decoration的说明:
text-decoration 属性规定添加到文本的修饰。
这个属性允许对文本设置某种效果,如加下划线。如果后代元素没有自己的装饰,祖先元素上设置的装饰会“延伸”到后代元素中。

这个属性只对文本有效啊?你是怎么出下划线的,能不能把代码贴出来给看看......

我晕,我试了下不会出现你说的情况啊

不做处理,图片都没有下划线的。

我刚看了下W3C对text-decoration的说明:
text-decoration 属性规定添加到文本的修饰。
这个属性允许对文本设置某种效果,如加下划线。如果后代元素没有自己的装饰,祖先元素上设置的装饰会“延伸”到后代元素中。

这个属性只对文本有效啊?你是怎么出下划线的,能不能把代码贴出来给看看......

我的网站是在IE11下,超链接的文字底部会被切除一部分。所以采用了下面的方法,这个方法你也提出过:
text-decoration:none;
border-bottom:1px soldi #000;
padding-bottom:2px;//为了border的显示更清晰。

但是如果向上面这样设置的话,超链接是图片时下面就会有线。

我觉得如果是文字的话里面可以在链接里面加一个span了,然后控制span的css。可以设置为:text-decoration:underline;图像的话就用
text-decoration:none;
border-bottom:1px soldi #000;
padding-bottom:2px;

我现在做的是维护项目,所以页面都已经写好了。现在浏览器升级到IE11的时候,超链接出现了问题。
所以像你所说的改法,估计改动范围比较大。所以不太可行。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the root tag in an HTML document?What is the root tag in an HTML document?Apr 29, 2025 am 12:10 AM

TheroottaginanHTMLdocumentis.Itservesasthetop-levelelementthatencapsulatesallothercontent,ensuringproperdocumentstructureandbrowserparsing.

Are the HTML tags and elements the same thing?Are the HTML tags and elements the same thing?Apr 28, 2025 pm 05:44 PM

The article explains that HTML tags are syntax markers used to define elements, while elements are complete units including tags and content. They work together to structure webpages.Character count: 159

What is the significance of <head> and <body> tag in HTML?What is the significance of <head> and <body> tag in HTML?Apr 28, 2025 pm 05:43 PM

The article discusses the roles of <head> and <body> tags in HTML, their impact on user experience, and SEO implications. Proper structuring enhances website functionality and search engine optimization.

What is the difference between <strong>, <b> tags and <em>, <i> tags?What is the difference between <strong>, <b> tags and <em>, <i> tags?Apr 28, 2025 pm 05:42 PM

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

Please explain how to indicate the character set being used by a document in HTML?Please explain how to indicate the character set being used by a document in HTML?Apr 28, 2025 pm 05:41 PM

Article discusses specifying character encoding in HTML, focusing on UTF-8. Main issue: ensuring correct display of text, preventing garbled characters, and enhancing SEO and accessibility.

What are the various formatting tags in HTML?What are the various formatting tags in HTML?Apr 28, 2025 pm 05:39 PM

The article discusses various HTML formatting tags used for structuring and styling web content, emphasizing their effects on text appearance and the importance of semantic tags for accessibility and SEO.

What is the difference between the 'id' attribute and the 'class' attribute of HTML elements?What is the difference between the 'id' attribute and the 'class' attribute of HTML elements?Apr 28, 2025 pm 05:39 PM

The article discusses the differences between HTML's 'id' and 'class' attributes, focusing on their uniqueness, purpose, CSS syntax, and specificity. It explains how their use impacts webpage styling and functionality, and provides best practices for

What is the 'class' attribute in HTML?What is the 'class' attribute in HTML?Apr 28, 2025 pm 05:37 PM

The article explains the HTML 'class' attribute's role in grouping elements for styling and JavaScript manipulation, contrasting it with the unique 'id' attribute.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor