How to align css icons with text

不言
Release: 2018-06-09 16:28:24
Original
2906 people have browsed it

The following will bring you two implementation methods of aligning CSS icons and text. The content is quite good, so I would like to share it with you now and give it as a reference for everyone.

In the process of writing pages, we often encounter the situation of aligning small icons with text. For example:

了 Summarized two methods, and the code volume was relatively small.

The first one

Set the vertical alignment of img to middle,

XML/HTML

1169 1168

Copy after login

XML/HTML

p{ height:30px; line-hight:30px; } .heart,.comment{ vertical-align:middle; }
Copy after login

Second type

Set the small icon as the background image and adjust padding

XML/HTML

1169 1168

Copy after login

JavaScript

.hear{ background:url(images/heart.png) left center no-repeat; margin-right:20px; } .comment{ background:url(images/comment.png) left center no-repeat; } .hear,.comment{ height:30px; line-height:30px; padding-left:20px; }
Copy after login

The above is The entire content of this article is hoped to be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use CSS to remove the select drop-down arrow

The above is the detailed content of How to align css icons with text. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!