以标记居中问题(Centering issue with tag)

编程入门 行业动态 更新时间:2024-10-20 06:39:59

标记居中问题(Centering issue with

tag)

我有一个img和一个div内的p 。

我试图垂直居中。 我已经尝试了line-height和其他一些事情。

这是它的样子

我想“可爱的火狐恶作剧”相对于img垂直居中

CSS

img{ width: 50px; height: 50px; } li{ list-style-type: none; text-decoration: none; } a{ text-decoration: none; } li p{ display: inline; color: black; font-size: 25px; margin:0; }

DEMO小提琴 。

I have a img and a p inside of a div.

I am trying to center the p vertically. I have tried line-height and a few other things.

Here is what it looks like

I would like "cute firefox prank" to be centered vertically relative to the img

CSS

img{ width: 50px; height: 50px; } li{ list-style-type: none; text-decoration: none; } a{ text-decoration: none; } li p{ display: inline; color: black; font-size: 25px; margin:0; }

DEMO fiddle.

最满意答案

完成。

更新了jsFiddle

你所要做的就是添加vertical-align:middle; 到img 。

img { vertical-align:middle; }

Done.

Updated jsFiddle

All you have to do is add vertical-align:middle; to the img.

img { vertical-align:middle; }

更多推荐

本文发布于:2023-07-16 12:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记   Centering   tag   issue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!