質問

I'm trying to use a themeroller icon on a page and it's not lining up where I'd expect. If I say:

    <html>
    <head>
    <title>Test Page</title>
    <link rel="stylesheet" type="text/css" media="screen" 
                          href="/css/ui-lightness/jquery-ui-1.8.17.custom.css" />
    </head>
    <body>
    <div><span class="ui-icon ui-icon-plusthick"></span>Hello World</div>
    </body>
    </html>

I would expect to see:

+Hello World

But instead I only see:

+

Why is this? And how do I get the result I'm expecting?

Thank you.

Edit 1: I followed the suggestion below to change the span to two tags (open and close, as shown above), but that didn't make any difference.

The relevant CSS seems to be:

.ui-icon
{
    display: block;
    text-indent: -99999px;
    overflow-x: hidden;
    overflow-y: hidden;
    background-repeat: no-repeat;
}

.ui-icon
{
    width: 16px;
    height: 16px;
    background-image: url("images/ui-icons_222222_256x240.png");
}

.ui-icon-plusthick 
{
    background-position: -32px -128px;
}

I tried changing the display: block to inline-block and other things, but it gets worse if I do.

Edit 3: Nevermind, I screwed up the code, it should have been:

 <span class="ui-icon ui-icon-plusthick" 
             style="display: inline-block"></span>Hello World</div>

And that works fine. (I misspelled "display")

役に立ちましたか?

解決

spans are not self closing must have a </span> to close it

span element on MDN

use:

<div><span class="ui-icon ui-icon-plusthick"></span>Hello World</div>

instead of:

<div><span class="ui-icon ui-icon-plusthick"/>Hello World</div>

他のヒント

Where did you close the span?

<html>
<head>
<title>Test Page</title>
<link rel="stylesheet" type="text/css" media="screen" 
                      href="/css/ui-lightness/jquery-ui-1.8.17.custom.css" />
</head>
<body>
<div><span class="ui-icon ui-icon-plusthick">&nbsp;</span>Hello World</div>
</body>
</html>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top