我正在 WebView 中加载一些 HTML 内容,但它总是出现在我的 WebView 的左上角。
我也尝试使用样式表,在样式表中我添加了与中心相关的标签,但它没有位于中心。样式表中的其他标签工作正常。
如何设置WebView中的内容垂直和水平居中?
我的 HTML 代码
<html><head> <style type=\"text/css\"> @font-face { font-family: MyCustomFont; src:url(\"file:///android_asset/fonts/MyriadPro-Regular.otf\") } body { font-family: MyCustomFont; font-size:14; text-align: center;vertical-align:middle;line-height: normal;} </style> </head><body> Hello World </body></html>
尝试这个:
<html>
<head>
<style type="text/css">
@font-face { font-family: MyCustomFont;
src:url("~/android_asset/fonts/MyriadPro-Regular.otf") }
#text{ font-family: MyCustomFont;
font-size:14;
text-align: center;
margin:350px;
line-height: normal;
color:blue;
height:20px;
width:100px;
margin:auto;
background-color:red;
}
</style>
</head>
<body>
<p id="text"> Hello World</p>
</body>
</html>
我认为你的地址源字体是错误的!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)