Can text overflow ellipsis target one element?
I'm trying to shorten a URL with text overflow ellipsis to keep things short in Mobile Safari.
Here is my code and page.
dd a {
text-overflow:ellipsis;
white-space:nowrap;
overflow:hidden;
width:2开发者_运维技巧0px;
background:red; /* for debugging */
}
You have the right start, the only problem is the rules aren't all being applied because a tags are inline by default and need to be block-level. Adding "display: block" to your CSS will do the trick and, luckily, because of the way you're styling your dds, it won't change your layout. Also, nix the 20px width :)
The question is a little hard to parse, but basically yes. The CSS selector could be for just one element. The easiest way would be to give the element an id, like id="mythingie"
and have the selector use that.
#mythingie {
text-overflow:ellipsis;
white-space:nowrap;
overflow:hidden;
width:20px;
background:red; /* for debugging */
}
Here, check out the new css3 selectors and you'll quickly be able to select whatever element you want :)
http://www.w3.org/TR/css3-selectors/#selectors
精彩评论