Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 文本旁边的背景图像不';工作_Html_Css - Fatal编程技术网

Html 文本旁边的背景图像不';工作

Html 文本旁边的背景图像不';工作,html,css,Html,Css,我有以下CSS代码: #left .gcontent { display: block; margin-bottom: 20px; border-radius:5px; width:300px; } #left .gcontent .head { background: #589fc6; border: 1px solid #3e82a7; padding-right: 8px; border-top-left-radius:5px; border-top-right-radius:5px; }

我有以下CSS代码:

#left .gcontent { display: block; margin-bottom: 20px; border-radius:5px; width:300px; }
#left .gcontent .head { background: #589fc6; border: 1px solid #3e82a7; padding-right: 8px; border-top-left-radius:5px; border-top-right-radius:5px; }
#left .gcontent .head h1 { color: #fafcfd; font-weight: bold; font-size: 1.1em; padding:0; margin:0; text-decoration:none; }
#left .gcontent .boxy { border-radius: 0px 0px 5px 5px; border: 1px solid #ccc; border-top: 0px; padding: 10px 8px; background: #f9f9f9; }
#left .gcontent .boxy span { font-size: 1.2em; display: block; margin-top: 7px; background-image:url(../images/main/left-arrow.png); background-repeat:no-repeat; background-size:15px 15px; clear:right;} 
#left .gcontent .boxy p {line-height:25px; }
这个HTML源代码

<div class="gcontent">
    <div class="head">
        <h1>TITLE </h1>
    </div>
    <div class="boxy">
        SOME TEXT
        <span>TEXTY TEXT</span>
    </div>
</div>

标题
一些文本
文本
问题是“左箭头”背景图像(在跨度中)位于左侧,与文本不太接近

我的问题是,我该如何解决这个问题,使图片与文本相邻


谢谢

您可以使用背景位置来定位背景图像:


你能提供一个吗?我不能,很抱歉(因为没有选项可以在那里看到图片,所以它将是无用的)…当使用JSFIDLE时,更改你的链接以使用图片的完整URL。在
#left.gcontent.boxy
中添加一个宽度,这样你可以将它变小或增加
右填充
我已经添加了CSS。对我来说,它起作用了。这是小提琴:谢谢!这确实更好,但问题是箭头附近的文本是动态的,因此箭头位置不能是静态的。然后看看这个小提琴:背景图像必须与文本宽度相同的容器对齐。欢迎您,哦,顺便说一下,display:inline现在实际上是不必要的,因为span无论如何都是一个内联元素。
#left .gcontent .boxy span
{
    font-size: 1.2em;
    display: block;
    margin-top: 7px;
    background-image: url('left-arrow.png');
    background-repeat: no-repeat;
    background-size: 15px 15px;
    clear: right;
    background-position: left;
    background-position: 200px 0px;
 }