[英]<button> image vs text alignment
as you can see in the image, when I use an image with just regular text the buttons are not aligned, if I use all text or all image it aligns perfectly as seen below. 正如您在图像中看到的那样,当我使用仅包含常规文本的图像时,按钮未对齐,如果我使用所有文本或所有图像,则按钮将完全对齐,如下所示。 i'm assuming this is a css problem?
我假设这是一个CSS问题?
<div style="text-align:center; border:1px solid; border-radius:5px; width:500px; margin: 10px auto 0px auto;">
<button type="button" onClick="parent.location='cal<?php echo $pyear;?>.php'" style="height:50px; width:50px;">
<?php echo $pyear;?>
</button>
<button type="button" onClick="parent.location='../index.php'" style="height:50px; width:50px">
<img src="../css/images/home_25.png" />
</button>
<button type="button" onClick="parent.location='cal<?php echo $nyear;?>.php'" style="height:50px; width:50px;">
<?php echo $nyear;?>
</button>
</div>
working example with all images as buttons. 所有图像作为按钮的工作示例。
By default the image
is aligned to the baseline of the text. 默认情况下,
image
与文本的基线对齐。 Simply use vertical-align: top
on all 3 buttons. 只需使用
vertical-align: top
所有3个按钮的vertical-align: top
。
<div style="text-align:center; border:1px solid; border-radius:5px; width:500px; margin: 10px auto 0px auto;">
<button type="button" onClick="parent.location='cal<?php echo $pyear;?>.php'" style="vertical-align: top;height:50px; width:50px;">
22222
</button>
<button type="button" onClick="parent.location='../index.php'" style="vertical-align: top;height:50px; width:50px">
<img src="http://placekitten.com/30/30" />
</button>
<button type="button" onClick="parent.location='cal<?php echo $nyear;?>.php'" style="vertical-align: top;height:50px; width:50px;">
11111
</button>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.