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

块元素、行内块和内联元素

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.

这个问题已经很流行了。 如何删除内联块元素之间的空格? 有趣的是,有许多解决方案,但是并非所有解决方案都很简单,而且大多数都需要JavaScript。 那么,刚刚开始编码但对JavaScript和其他语言一无所知的人呢? 好了,没有什么可担心的,有一些答案不需要您使用JavaScript。 因此,让我们继续前进,看看这是怎么可能的。

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.

这个问题有两个答案,但我们将只讨论其中三个。 由于您不希望在编码的初始阶段感到困惑,因此这些答案是最好的,而且它们很容易理解和实现。 因此,让我们毫不拖延地继续回答。

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代码以实现所需的功能,即删除行内块元素之间的空格。

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.

好吧,这听起来很简单,但是怎么做到的呢? 为此,您将必须查看以下语法以进行适当的理解。

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的一种方法,除此之外,还有另一种方法可以使您获得相同的结果。 因此,请查看下面的语法以了解它。

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.

这里的代码似乎有点怪异, 它不是常规代码,但是仍然可以消除内联块元素之间的空格。 好吧,这两个肯定会起作用,但是还有一个技巧可以用来解决问题。

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.

您会惊奇地知道这个把戏。 在此技巧中,您要做的就是在创建内联块元素时利用注释。 好吧,是的,这听起来有点令人困惑,但是窍门非常有效,您一定会得到想要的东西。 因此,请看一下实现的语法。

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.

这里的代码似乎有点怪异, 它不是常规代码,但是仍然可以消除内联块元素之间的空格。 好吧,这两个肯定会起作用,但是还有一个技巧可以用来解决问题。

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.

您会惊奇地知道这个把戏。 在此技巧中,您要做的就是在创建内联块元素时利用注释。 好吧,是的,这听起来有点令人困惑,但是窍门非常有效,您一定会得到想要的东西。 因此,请看一下实现的语法。

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

输出量

How to remove the space between inline-block elements?

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开发,那么这些技巧一定会在遇到相同问题时为您提供帮助,否则,您总是可以自由探索其他技巧您可能会找到合适的。

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

块元素、行内块和内联元素

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/545839.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring--quartz中cronExpression 的配置方法

Spring--quartz中cronExpression Java代码 字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1-31 , - * ? / L W C 月份 1-12 或者 JAN-DEC , - * /…

C语言图形库——EasyX基本贴图

在C语言的学习过程中&#xff0c;接触最多的就是黑乎乎的DOS窗口&#xff0c;这也是在消磨学习者的兴趣&#xff0c;学到最后可能还不知道C语言到底能做什么&#xff0c;难道就是输入输出数据吗&#xff1f;当然不是&#xff0c;C的用处很广泛&#xff0c;这里不做讨论。我们能…

HTML5-特效

HTML5-特效-跟随鼠标的粒子<!DOCTYPE html> <html lang"en"><head><meta charsetutf-8><title>Liquid Particles - spielzeugz.de canvas experiment </title><meta name"description" content"HTML5/canvas …

一气之下,手撸了一个抖音去水印的工具!

百因必有果说一下我为什么要做个抖音视频去水印工具&#xff0c;其实是因为我的沙雕女友&#xff0c;她居然刚我~有天晚上她在抖音看见一个非常具有 教育意义 的视频&#xff0c;“男人疼媳妇就该承包全部家务活”&#xff0c;然后它就想把视频下载下来&#xff0c;分享到她的姐…

css 隐藏元素 显示元素_使用CSS打印时如何隐藏元素?

css 隐藏元素 显示元素Introduction: 介绍&#xff1a; We have come across many challenges while developing a website or web page and every challenge comes with new learnings. It is a trait of a good developer who develops or creates websites or web pages by…

C语言图形库——EasyX常用函数

上节讲到贴出一张图片的过程&#xff0c;本节接着介绍一些基本的图形库函数。 头文件 #include <graphics.h>1、图形窗口背景颜色设置函数&#xff1a; 例 setbkcolor(YELLOW)&#xff1b;//将图形窗口背景颜色设置为黄色。也可用 setbkcolor(RGB(180,24,137));利用三…

Adobe_Audition消除人声

傻瓜式: 方法一&#xff1a;效果 - 立体声声像 - 声道重混缩 - 选择Vocal Cut 新建左声道(左100;右-100) 新建右声道(左-100;右100;反相) 方法二&#xff1a;效果 - 立体声声像 - 析取中置通道 - Karaoke(效果预置) - 男声. (测试后&#xff0c;在傻瓜式中这种方法效果最好) 方…

Java新特性:数据类型可以扔掉了?

作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;在很久很久以前&#xff0c;我们写代码时要慎重的考虑变量的数据类型&#xff0c;比如下面这些&#xff1a;枚举&#xff1a…

Spyder:Python中机器学习的强大武器

So, first of all, you would need to install Anaconda distribution which can be downloaded from the link https://www.anaconda.com/download/ (for Windows users only). 因此&#xff0c;首先&#xff0c;您需要安装Anaconda发行版 &#xff0c;可以从链接https://www.…

C语言+数据结构总结

一、C语言部分 1、数据类型&#xff1a; Int 整形 4字节Short 短整形 2字节Long 长整形 4字节Float 单精度浮点型 4字节Double 双精度浮点型 8字节Char 字符型 1字节2、变量 …

对内存重叠的深入认识

内存重叠&#xff1a;拷贝的目的地址在源地址范围内。所谓内存重叠就是拷贝的目的地址和源地址有重叠。在函数strcpy和函数memcpy都没有对内存重叠做处理的&#xff0c;使用这两个函数的时候只有程序员自己保证源地址和目标地址不重叠&#xff0c;或者使用memmove函数进行内存拷…

Android特效 五种Toast具体解释

Toast是Android中用来显示显示信息的一种机制&#xff0c;和Dialog不一样的是&#xff0c;Toast是没有焦点的&#xff0c;并且Toast显示的时间有限&#xff0c;过一定的时间就会自己主动消失。 1.默认效果: 代码:Toast.makeText(getApplicationContext(), "默认Toast样式&…

为什么阿里巴巴禁止使用BigDecimal的equals方法做等值比较?

△一个对Coding有着独特追求的人△作者 l Hollis来源 l Hollis&#xff08;ID&#xff1a;hollischuang&#xff09;BigDecimal&#xff0c;相信对于很多人来说都不陌生&#xff0c;很多人都知道他的用法&#xff0c;这是一种java.math包中提供的一种可以用来进行精确运算的类型…

日期getUTCMonth()方法以及JavaScript中的示例

JavaScript Date getUTCMonth()方法 (JavaScript Date getUTCMonth() method) getUTCMonth() method is a Dates class method and it is used to get the current month’s value according to the UTC (Universal time coordinated) between the range of 0 to 11, where 0 f…

VB另类技巧(可以用于VBA)-指针的使用

大家都知道C中可以使用指针&#xff0c;但现在VB&#xff08;当然也有VBA&#xff09;也可以使用指针了&#xff0c;这是我在网上看的一篇文章&#xff0c;大家参考一下。想当年东方不败&#xff0c;黑木崖密室一战&#xff0c;仅凭一根绣花针独战四大高手&#xff0c;神出鬼没…

动图演示:手撸堆栈的两种实现方法!

作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;正式开始之前&#xff0c;先和各位朋友聊聊公众号后期的一些打算&#xff0c;后面的文章计划写一些关于数据结构和算法的内容…

Java中的异常处理

1 class YiChang{2 public static void main(String[] args){3 A anew A();4 a.show();5 }6 }7 8 class A{9 int[] i{1,2,3}; 10 public void show(){ 11 System.out.println(i[3]); 12 } 13 } 运行上面代码&#xff0c;会抛出这样…

数组copyWithin()方法以及JavaScript中的示例

JavaScript copyWithin()方法 (JavaScript copyWithin() method) copyWithin() method is used to copy the specified elements from an array and replace from specified index within the same array. It changes the this array (actual array). copyWithin()方法用于从数…

多图带你彻底理解Java中的21种锁!

作者 | 悟空聊架构来源 | 悟空聊架构&#xff08;ID&#xff1a;PassJava666&#xff09;本篇主要内容如下&#xff1a;本篇主要内容本篇文章已收纳到我的Java在线文档、 Github我的SpringCloud实战项目持续更新中帮你总结好的锁&#xff1a;序号锁名称应用1乐观锁CAS2悲观锁sy…

杨辉三角——数组解决

杨辉三角如图下所示&#xff0c;每一行的第一个数和最后一个数都为1&#xff0c;每一行中间的数&#xff08;出去第一个和最后一个&#xff09;a等于上一行与其相同列数的数b与数b前面的数之和。例&#xff1a; 第3行第2列的数是3&#xff0c;它就等于第2行第2列的数&#xff…