【问题标题】:Don't allow margin of element being clicked to change page不允许单击元素的边距来更改页面
【发布时间】:2019-11-22 15:50:12
【问题描述】:

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

代码:

                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))})

【问题讨论】:

  • 如果需要,我可以添加任何其他屏幕截图 --> 不需要更多屏幕截图,我们需要代码
  • stackoverflow.com/help/minimal-reproducible-example ---> 请勿使用代码图片。
  • @TemaniAfif 我刚刚添加了代码,我认为这两个图像就足够了,因为我在图像中添加了计算的样式
  • 一个好的问题应该包含minimal reproducible example - 你有足够的代表知道这一点。图片不是一个“好的”解决方案,因为它需要社区“猜测”问题可能是什么(因为我们没有所有必要的信息)

标签: html css margin center


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    header 放入div,并给div 一个类,然后给它以下属性:

    display: flex;
    width: 100%;
    justify-content: center;
    

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 2020-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多