【发布时间】:2015-08-13 11:05:10
【问题描述】:
我正在尝试从 alt 标记文本中删除边框。我正在使用透明图像作为贝宝表单中的按钮,通过 css 链接。 paypal 按钮将 alt 标签作为按钮文本并在其周围放置边框。我不清楚为什么会发生这种情况,但这是我必须从贝宝处理的。显然我必须使用图像。所以我使用了一个透明图像,所以我可以在 css 中设置它的样式,让它看起来像我的其他按钮,而不是尝试获取每个按钮状态的屏幕截图。
我将代码配对,只关注文本“查看购物车”周围的边框。
CSS
//link to my transparent button with no text on it
#vyc {
background-image: url(http://lakenney.com/kenney_lucille-final/images/vyc.png) no-repeat;
}
//the user agent that is controlling the outer border
user agent stylesheetinput[type="hidden" i], input[type="image" i], input[type="file" i] {
-webkit-appearance: initial;
padding: 20px;
background-color: initial;
border: dotted;
border-top-color: red;
}
//a couple of tags I'm using to try to access the alt tag border not working
#vyc img[alt] {
/*border: 1px dashed #3D8EA5;*/
border: transparent !important;
}
input#vyc img[alt] {
border: transparent !important;
}
HTML
这里是相同代码的 jsfiddle 链接: http://jsfiddle.net/lakenney/w0zpmutn/
【问题讨论】:
-
我正在使用 input type="image" 因为它是一个贝宝按钮。我必须使用图像。所以我试图通过使用 input type="image" 并链接到透明图像来解决这个问题,以便我可以设置它的样式。除了我在 alt 标签周围得到那个边框之外,这一切都有效。我试图弄清楚使用什么 css 元素来为该图像设置 alt 标签的样式。也许我正在尝试做的事情不可行?
-
@humble.rumble 有趣。但是一旦我链接到 html 中的图像,alt 文本就不再可见,这是有道理的,因为 alt 标记的作用是在图像丢失时代替图像。也许我可以通过遍历 DOM 来访问 input 的子项,并以某种方式获得 alt。那可能值得一试。或者,可以创建带有文本的透明图像,然后使用 css 对其进行样式设置。那可能行得通。我总是可以将按钮创建为图像,但我认为应该有更好的方法。我只是在脑子里乱扔东西。 :)
-
@humble.rumble 将图像 url 放在 html 中并使用覆盖对我来说需要更多的调整!你是个天才!谢谢! jsfiddle.net/lakenney/w0zpmutn