CSS solves the misalignment problem of inline-block

CSS solves the misalignment problem of inline-block

No more nonsense, post code

HTML part

<div class="positionleft">I am on the left side of the position method, accounting for 30%</div>
        <div class="positionright">I am on the right side of the position method, accounting for 70%</div>

CSS part

 .positionleft {
           position: relative;
           display: inline-block;
           background-color: #8d8d8d;
           width: 30%;
           height: 20%;

       }
       .positionright {
           position: relative;
           display: inline-block;
           left: 0;
           background-color: #ff8888;
           width: 70%;
           height: 20%;
       }

Display Effect

insert image description here

It can be clearly seen that the two div blocks are misaligned. After consulting the information, it is found that this phenomenon occurs when there is a space between the two inline-blocks.

Modify the html code as follows

<div class="positionleft">I am on the left side of the position method, accounting for 30%</div> <div class="positionright">I am on the right side of the position method, accounting for 70%
</div>

Just delete the space between the two divs and see the effect.

insert image description here

Problem Solving

Please pay attention to this problem when using document formatting tools such as prettier

Summarize

This is the end of this article about how to solve the misalignment problem of inline-block with CSS. For more relevant CSS inline-block misalignment content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  JS cross-domain XML--with AS URLLoader

>>:  Detailed explanation of anonymous slots and named slots in Vue

Recommend

Detailed explanation of the execution process of mysql update statement

There was an article about the execution process ...

Understand the principles of MySQL persistence and rollback in one article

Table of contents redo log Why do we need to upda...

Detailed explanation of system input and output management in Linux

Management of input and output in the system 1. U...

MySQL index optimization: paging exploration detailed introduction

Table of contents MySQL Index Optimization Paging...

Implementation code for using CSS text-emphasis to emphasize text

1. Introduction In the past, if you wanted to emp...

Summary of some of my frequently used Linux commands

I worked in operations and maintenance for two ye...

Detailed explanation of reduce fold unfold usage in JS

Table of contents fold (reduce) Using for...of Us...

How CSS affects the white screen time during initial loading

Rendering pipeline with external css files In the...

Problem record of using vue+echarts chart

Preface echarts is my most commonly used charting...

HTML+CSS merge table border sample code

When we add borders to table and td tags, double ...

How to improve MySQL Limit query performance

In MySQL database operations, we always hope to a...

MySQL 5.7.16 ZIP package installation and configuration tutorial

This article shares the installation and configur...

Vue+Vant implements the top search bar

This article example shares the specific code of ...

Nest.js authorization verification method example

Table of contents 0x0 Introduction 0x1 RBAC Imple...