日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

块元素、行内块和内联元素_如何删除内联块元素之间的空间?

發(fā)布時間:2025/3/11 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 块元素、行内块和内联元素_如何删除内联块元素之间的空间? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

塊元素、行內(nèi)塊和內(nèi)聯(lián)元素

Introduction:

介紹:

This question has become rather popular. How does one remove whitespaces between the inline-block elements? The interesting thing is there are numerous solutions to this but not all of them are easy and most of them require JavaScript and all. So, what about people who have just started coding and have no idea about JavaScript and other languages? Well, there is nothing to be worried about, there are answers which do not require you to make use of JavaScript. So, let us move on and see how that is possible.

這個問題已經(jīng)很流行了。 如何刪除內(nèi)聯(lián)塊元素之間的空格? 有趣的是,有許多解決方案,但是并非所有解決方案都很簡單,而且大多數(shù)都需要JavaScript。 那么,剛剛開始編碼但對JavaScript和其他語言一無所知的人呢? 好了,沒有什么可擔(dān)心的,有一些答案不需要您使用JavaScript。 因此,讓我們繼續(xù)前進,看看這是怎么可能的。

Solutions:

解決方案:

There are a couple of answers to this question but we will discuss only three of them. As you don't want to be confused in your initial stage of coding besides these answers are the best and they are very easy to understand and implement. So, without much delay let us move on with the answers.

這個問題有兩個答案,但我們將只討論其中三個。 由于您不希望在編碼的初始階段感到困惑,因此這些答案是最好的,而且它們很容易理解和實現(xiàn)。 因此,讓我們毫不拖延地繼續(xù)回答。

Method 1:

方法1:

First and foremost, you can solve this problem by using minimized HTML. Well, what does that mean? Right, it means that you can minimize the code of your HTML to achieve what you desire and that is to remove spaces between in-line block elements.

首先,您可以通過使用最小化HTML來解決此問題。 好吧,那是什么意思? 正確,這意味著您可以最小化HTML代碼以實現(xiàn)所需的功能,即刪除行內(nèi)塊元素之間的空格。

Well, it sounds pretty easy but how does one do it? For that, you will have to look at the syntax below for proper understanding.

好吧,這聽起來很簡單,但是怎么做到的呢? 為此,您將必須查看以下語法以進行適當(dāng)?shù)睦斫狻?

Syntax:

句法:

<ul> <li> first</li><li> second</li><li> third</li><li> </ul>

Method 2:

方法2:

Well, this was one method of minimizing HTML, there is one more way besides this one by which you can achieve the same result. So, look at the syntax below to get the idea.

好吧,這是最小化HTML的一種方法,除此之外,還有另一種方法可以使您獲得相同的結(jié)果。 因此,請查看下面的語法以了解它。

Syntax:

句法:

<ul> <li>first</li ><li>second</li ><li>third</li> </ul>

The code here might seem a bit weird and it is not the conventional code but still, this trick helps in removing the spaces between the inline-block elements. Well, these two would surely work but there is one more trick that you can use for solving the problem.

這里的代碼似乎有點怪異, 它不是常規(guī)代碼,但是仍然可以消除內(nèi)聯(lián)塊元素之間的空格。 好吧,這兩個肯定會起作用,但是還有一個技巧可以用來解決問題。

Method 3:

方法3:

You would be amazed to know this trick. In this trick, all you need to do is make use of comments while creating inline-block elements. Well, yes it sounds a bit confusing but the trick is very efficient and you will surely get what you desire. So have a look at the syntax for the implementation.

您會驚奇地知道這個把戲。 在此技巧中,您要做的就是在創(chuàng)建內(nèi)聯(lián)塊元素時利用注釋。 好吧,是的,這聽起來有點令人困惑,但是竅門非常有效,您一定會得到想要的東西。 因此,請看一下實現(xiàn)的語法。

Syntax:

句法:

<ul> <li>first</li><!-- --><li>second</li><!-- --><li>third</li> </ul>

The code here might seem a bit weird and it is not the conventional code but still, this trick helps in removing the spaces between the inline-block elements. Well, these two would surely work but there is one more trick that you can use for solving the problem.

這里的代碼似乎有點怪異, 它不是常規(guī)代碼,但是仍然可以消除內(nèi)聯(lián)塊元素之間的空格。 好吧,這兩個肯定會起作用,但是還有一個技巧可以用來解決問題。

You would be amazed to know this trick. In this trick, all you need to do is make use of comments while creating inline-block elements. Well, yes it sounds a bit confusing but the trick is very efficient and you will surely get what you desire. So have a look at the syntax for the implementation.

您會驚奇地知道這個把戲。 在此技巧中,您要做的就是在創(chuàng)建內(nèi)聯(lián)塊元素時利用注釋。 好吧,是的,這聽起來有點令人困惑,但是竅門非常有效,您一定會得到想要的東西。 因此,請看一下實現(xiàn)的語法。

Syntax:

句法:

<ul> <li>first</li><!-- --><li>second</li><!-- --><li>third</li> </ul>

Example:

例:

<!DOCTYPE html><html><head><style>ul {list-style: none}li {background: pink;display: inline-block;padding: 4px;}</style> </head><body><ul><li>this</li><li>is</li><li>Includehelp</li></ul> </body></html>

Output

輸出量

Well, these tricks are pretty amazing. But these are not all, there are more tricks out there but if you have just started your work in web development then these tricks would surely help you whenever you come across the same problem and otherwise, you are always free to explore some other tricks which you may find suitable.

好吧,這些技巧真是太神奇了。 但這還不是全部,還有更多的技巧,但是如果您剛開始進行Web開發(fā),那么這些技巧一定會在遇到相同問題時為您提供幫助,否則,您總是可以自由探索其他技巧您可能會找到合適的。

翻譯自: https://www.includehelp.com/code-snippets/how-to-remove-the-space-between-inline-block-elements.aspx

塊元素、行內(nèi)塊和內(nèi)聯(lián)元素

總結(jié)

以上是生活随笔為你收集整理的块元素、行内块和内联元素_如何删除内联块元素之间的空间?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。