首页 > 解决方案 > 不允许单击元素的边距来更改页面

问题描述

目前我在锚元素中有一个标题元素,但是我正在使用规则margin: 0 auto使标题居中,这会在每一侧留下 232px 的边距,如果单击它将更改页面。如何在不留下单击时会更改页面的边距的情况下使此标题居中?谢谢,如果需要,我可以添加任何其他屏幕截图

代码:

                a(href=`${story.url}`)
                    h5.disabled.balance-text(style="width:466px;margin:0 auto;") #{story.title}
                    br
                    img(src=`${story.storyImageUrl}` style="width:400px;")
                    br
                    br
                    p.balance-text(style="width:440px;margin: 0 auto;color:black") #{story.description} (#{timeAgo.format(new Date(story.publishedAt))})

在此处输入图像描述

在此处输入图像描述

标签: htmlcssmargincenter

解决方案


将元素包装在容器中,并在包含的项目仍与单击处理程序绑定时对其应用边距和宽度


推荐阅读