Help us understand the problem. What is going on with this article?

inline要素を横並びにしてできる隙間を消す

More than 1 year has passed since last update.

要素をinlineにして横並びにすると、デザイン上、隙間が生まれます。原因は改行コードなので、HTMLで改行を行わなければいいのですが、コードの見栄え的によくありません。

また<!-- -->(コメントアウト)で改行による隙間を消すこともできますが、
こちらも見栄えとしてあまりいいとは思わないので、letter-spacingを使って消していきます。

HTML

<ul class="list">
    <li>aaa</li>
    <li>bbb</li>
    <li>ccc</li>
</ul>

CSS

.list {
    letter-spacing: -.4em;/*文字を詰める(隙間を消す)*/
}
.list > li {
    display: inline;
    letter-spacing: normal;/*文字間を元に戻す(隙間は消えたまま)*/
}

以上です。他にも色々な方法がありますが、個人的にはこれがベターかなと思いました。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away