2

我的代码结构如下:

<article style="font-size:16px;text-indent:40px;line-height:1.5em;">
<ul>
  <li><a title="Egypt" href="#egypt" style="text-indent:0px;padding-left: -25cm;">Egypt</a></li>
</ul>
</article>

是的,必须依赖于现在不用担心。

这将使埃及获得该国的text-indent财产<article>。但是,我希望这种情况不要发生。我希望埃及,列表项,有 0 文本缩进!

怎么做?

检查js-fiddle

4

3 回答 3

5

在下面的代码段中将移动text-indent: 0pxli而不是a类似。

text-indent属性仅适用于块容器li是一个块容器,而a 不是,因此设置它a没有效果。

此外,这个属性是一个继承的属性,这就是为什么li40px 从article. 如果您检查li并查看“计算”样式部分,您会注意到这一点。

<article style="font-size:16px;text-indent:40px;line-height:1.5em;">
  <p>
    Goal of this page is to laconically detail where I, <strong>Georgios Samaras</strong> have travelled, since I am asked again and again and usually I forgot some places.
  </p>
  <p>
    I will list (in random order) were I have been to and say some more about the non-Greek places I have been after 2012. It's also good to write down the memories... :)
    <ul>
      <li style="text-indent: 0px;"><a title="Egypt" href="#egypt">Egypt</a>
      </li>
    </ul>
</article>

于 2016-05-28T11:26:05.137 回答
2

问题已解决,从文章中删除样式并将其应用于 p

工作小提琴

<article>
<p style="font-size:16px;text-indent:40px;line-height:1.5em;">Goal of this page is to laconically detail where I, <strong>Georgios Samaras</strong> have travelled, since I am asked again and again and usually I forgot some places.
</p>
<p>
I will list (in random order) were I have been to and say some more about the non-Greek places I have been after 2012. It's also good to write down the memories... :)
<ul>
  <li><a title="Egypt" href="#egypt">Egypt</a></li>
</ul>
</article>
于 2016-05-28T11:29:39.457 回答
1

从 HTML 中删除style="(...)"并添加它,也许这会有所帮助:

ul {
    list-style-position: inside;
    padding-left:0;
}

就是这样,只有这几行。

于 2016-05-28T11:26:43.203 回答