html - 垂直对齐打破文本下划线
问题描述
我将垂直对齐设置为以我的个人资料图像为中心。就我而言,垂直对齐与个人资料图像完美。问题是下划线文本在 Tom 的左侧中断。我怎样才能将我的垂直对齐设置为中间,并且文本不会在 Tom 单词的左侧中断?
http://jsfiddle.net/5zrxd9c1/1/
<a href="/user/tomjones" class="image" title="View profile">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Macaca_sinica_-_01.jpg/220px-Macaca_sinica_-_01.jpgn" class="gravatar" width="28" height="28" style="border-radius: 50px; padding:2px;border: 2px solid #fff;" alt="">
<span style="height: 33px;display: table-cell;vertical-align: middle;/* ext-underline-position: inherit; *//* margin-top: -5px; */" class="username">
Tom Jones
</span>
</a>
CSS:
.username {
height: 33px;
display: table-cell;
vertical-align: middle;
}
body {
background-color:powderblue;
}
解决方案
你能试试这个吗
点击这里 https://jsfiddle.net/kblau237/sdc28tg7/
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Tut124</title>
<style type="text/css">
.username {
height: 33px;
/*!!! removed this*/
/*display: table-cell;*/
/*vertical-align: middle;*/
/*!!!added these*/
position: absolute;
left: 50px;
top: 18px;
}
body {
background-color: powderblue;
}
</style>
</head>
<body>
<a href="/user/tomjones" class="image" title="View profile">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Macaca_sinica_-_01.jpg/220px-Macaca_sinica_-_01.jpgn"
class="gravatar" width="28" height="28" style="border-radius: 50px; padding:2px;border: 2px solid #fff;"
alt="">
@*!!!Changed the display to table-row removed vertical-align: middle;*@
<span style="height: 33px;display: table-row;text-decoration:underline" class="username">Tom Jones</span>
</a>
</body>
</html>
推荐阅读
- angular - 嵌入包含更多内容的内容以嵌入到子组件中
- php - 在后台覆盖 AdminHtml 控制器
- listview - JavaFX Listview 在 1 条上堆叠数据
- python - 打印到 CSV 打印标题每次迭代
- vue.js - nuxt :点击 nuxt-link 后调用 nuxtServerInit
- typescript - 强制数组在联合类型上是详尽的
- hive - 如何从 Hive/Impala 中的字符串列中删除前导零
- time - 比较 While 控制器 jmeter 5.0 上的语法
- paypal - PayPal 通过 NVP API 向用户授予权限
- java - java程序重启时的反序列化