如何设置替代文本颜色样式?
我想设置地图区域图像的替代文本颜色 -> alt="维多利亚的秘密" 默认是蓝色,但我想是红色! 我尝试了一些方法但没有成功...有什么帮助吗?
这是我的代码:
<map name="Map" id="Map">
<area shape="rect" coords="22,4,126,50" href="http://www.victoriassecret.com/" target="_blank" alt="Victoria's Secret"/>
I want to style alt text color of map area image -> alt="Victoria's Secret"
By default is blue, but I want to be red!
I tried some methods without sucess... Any help?
This is my code:
<map name="Map" id="Map">
<area shape="rect" coords="22,4,126,50" href="http://www.victoriassecret.com/" target="_blank" alt="Victoria's Secret"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与普遍看法相反,“替代文本”并不是将鼠标悬停在项目上时显示的系统生成的消息。您在其中看到的文本是在元素的 title 属性中设置的,无法设置样式。
但是,实际的替代文本(即未加载图像时显示的文本)可以像在任何其他元素中设置文本样式一样设置样式。例如:
将使替代文本变为红色并在容器内水平居中。
但是,如果这根本不是您的意思,并且您指的是系统生成的工具提示,那么您将需要遵循 ose 的建议并创建自定义工具提示,这可能需要更多的工作比你预期的要多。
不过,我建议您使用纯 HTML/CSS 工具提示,因为并不是每个人都启用 JavaScript。这似乎是一个不错的,我刚刚在 Google 上搜索到:纯 CSS 工具提示
"Alt text" is, contrary to popular belief, not the system-generated message that shows up when hovering over items. The text you see in those is set in the title attribute of the element and cannot be styled.
However, the actual alt text, being the text that is displayed when an image is not loaded can be styled like you would style text in any other element. For example:
will make the alternate text red and horizontally center it within the container.
However, if that is not at all what you meant, and you meant the system-generated tooltips, you'll want to follow ose's advice and create a custom tooltip, which will probably take a bit more work than you intended.
I'd advice you to go with a pure HTML/CSS tooltip though, as not everyone has JavaScript on. This seems like an okay one I just Googled up: Pure CSS Tooltips
您能否更具体地说明您的目标平台、语言等。
我假设您正在尝试更改 HTML 页面中的替代文本。
不幸的是,这是不可能的请参阅此处因为替代文本是由浏览器/操作系统设置的。
除此之外,替代文本通常用于提高网站的可访问性。即使您可以更改它,您也应该不理会它。
如果您想创建工具提示(弹出文本),那么有许多 DHTML 脚本可用于执行此操作比如这样
Can you be more specific in your target platform, language etc.
I am assuming you are trying to change the alt text in a HTML page.
This is unfortunately not possible see here as alt text is set by the browser/operating system.
Aside from which, alt text is generally used to improve the accessibility of the site. You should probably leave this alone even if you could change it.
If you want to create a tooltip (popup text), then there are many DHTML scripts out there for doing that such as this