javascript - 当 div 内的标签具有内联文本对齐以对齐时,如何在 div 左侧对齐文本

标签 javascript html css model-view-controller text-align

我想修复网站的前 View 。我只是一个初学者。在 p 标签中有值的长描述中出现的问题。
笔记本电脑 View :
enter image description here

手机查看:
enter image description here

检查中的 CSS:我不知道从哪里来 Class="MsoNormal"和样式 来自 BLDes,但我必须修复它。
enter image description here
背后的代码:

<div class="uni-entry-description" style="text-align:left !important">
                                                        <p>
                                                            @Html.Raw(Model.BLDes)
                                                        </p>
                                                    </div>
Model.BLDes 的值是编辑我的富文本编辑器。所以,它包含一些 p 标签。 div 内联 css 在其中不起作用。

inspect 中的第一个 p 标签来自代码,而其他 p 标签是 BLDes 的值。

我在 div 中使用了内联 css !重要 关键字,但它不起作用。我也将媒体查询用于移动 View 但不起作用。
我在这里先向您的帮助表示感谢。
到目前为止我尝试过的:
  • Spacing between some words is just too big in mobile view when text is justified
  • Disable inline css style
  • Remove a specific inline style with Javascript|jQuery
  • 最佳答案

    谢谢大家。谁阅读了这篇文章并为它做出了贡献。

    问题在Remove a specific inline style with Javascript|jQuery的帮助下解决了.

    我只是从页面的顶部到底部更改脚本标记的位置。

    <script>
        let declaration = document.getElementsByClassName("MsoNormal");
        for (let i = 0; i < declaration.length; i++) {
            declaration[i].style.removeProperty("text-align");
        }    
    </script>
    
    如果有人向我解释为什么更改脚本的位置可以解决问题,那对我以后真的很有帮助。为了避免这样的错误。提前致谢

    [编辑]
    更改上面的代码,使任何没有 MsoNormal 类的标签仍然向左对齐
    let allElementInDiv = document.getElementsByClassName("uni-entry-description");
        for (let i = 0; i < allElementInDiv[0].children.length; i++) {
            allElementInDiv[0].children[i].style.removeProperty("text-align");
        }
    

    关于javascript - 当 div 内的标签具有内联文本对齐以对齐时,如何在 div 左侧对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67942057/

    相关文章:

    javascript - 是否有用于鼠标光标选择的文本的 javascript/jquery 选择器?

    javascript - $http请求一次返回所有记录不分页

    php - HTML php 本地主机数据库检索

    html - CSS/CSS3 背景随内容自动增加

    html - 如何在 visible-xs 和 visible-sm bootstrap 中旋转 img

    javascript - 在 iOS (PhoneGap) 上滚动停止后才会呈现图像

    将 html 移动到父站点后,Javascript 停止工作

    Javascript:重定向页面 onclick

    html - 如何用纯css设计类似大网站

    html - 根据用户显示器的尺寸/分辨率动态调整 div 的高度