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

mysql server is running with the --skip-grant-tables option

The MySQL server is running with the --skip-grant...

XHTML Getting Started Tutorial: Form Tags

<br />Forms are an important channel for use...

Complete steps to implement face recognition login in Ubuntu

1. Install Howdy: howdy project address sudo add-...

MySQL case when usage example analysis

First we create the database table: CREATE TABLE ...

How to use Font Awesome 5 in Vue development projects

Table of contents Install Dependencies Configurat...

Vue ElementUI implements asynchronous loading tree

This article example shares the specific code of ...

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

Example of deploying MySQL on Docker

Table of contents 1 What is container cloud? 2 In...

CSS multi-level menu implementation code

This is a pretty cool feature that makes web page...

How to implement Linux automatic shutdown when the battery is low

Preface The electricity in my residence has been ...

MySQL 5.6 root password modification tutorial

1. After installing MySQL 5.6, it cannot be enabl...

Vue encapsulation component upload picture component

This article example shares the specific code of ...

Summary of various implementation methods of mysql database backup

This article describes various ways to implement ...

Nginx proxy forwarding implementation code uploaded by Alibaba Cloud OSS

Preface Because the mini program upload requires ...

Use of Vue3 table component

Table of contents 1. Ant Design Vue 1. Official w...