HarmonyOS 鸿蒙Next Web组件展示页面片 h5内容会超出Web组件宽度
HarmonyOS 鸿蒙Next Web组件展示页面片 h5内容会超出Web组件宽度
使用Web组件展示HTML标签富文本,h5内容宽度超出了Web组件限制的宽度,导致页面右边内容显示不全,且会左右滑动。
页面内容:
<!DOCTYPE html>
<html>
<head>
<title>Rich_Text</title>
<style>
html {
-webkit-text-size-adjust: 100%;
text-align: right;
}
div {
font-size: 15px;
color: #666666;
}
a {
color: #3389DF;
text-decoration: none;
}
span {
color: #333333;
}
strong {
color: #000000;
}
</style>
</head>
<body>
<div class='container'>
<font color='#DF1F26'>05月22日</font>
</div>
</body>
</html>
2 回复
给html设置<meta name="viewport" content="width=device-width, initial-scale=1.0">即可
const HTMLRichTextTemplate = `
<html>
<head>
<title>Rich_Text</title>
<meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
<style>
html {
-webkit-text-size-adjust: 100%;
text-align: right;
}
div {
font-size: 15px;
color: #666666;
}
a {
color: #3389DF;
text-decoration: none;
}
span {
color: #333333;
}
strong {
color: #000000;
}
</style>
</head>
<body>
<div class=‘container’>
<font color=’#DF1F26’>05月22日</font>
</div>
</body>
</html>`
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>