布局在 Google Chrome 上看起来很完美,但在 Mozilla Firefox 上却不是

时间:2021-07-12 13:47:22

标签: css google-chrome firefox layout browser

index.vue

<template>
  <div>
    <Tasks />
  </div>
</template>

Tasks.vue

  <div class="tasks-container">
    <div class="tasks">
      <div class="tasks-item">
        <div class="tasks-task">
          <span class="label"></span>
          <h1>Lorem ipsum dolor sit amet conse pisicing elit</h1>
        </div>
        <button>abc</button>
      </div>
      <br />
      <div class="tasks-item">
        <div class="tasks-task">
          <span class="label"></span>
          <h1>Lorem ipsum dolor sit amet</h1>
        </div>
        <button>xyz</button>
      </div>
    </div>
  </div>
</template>

<style scoped>
.tasks-container {
  max-width: 1000px;
  margin: auto;
}
.tasks {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tasks-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f8f8;
  padding: 25px 30px;
}
.tasks-task {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 65%;
}
.tasks-task .label {
  width: 70px;
  height: 70px;
  background: #947777;
  border-radius: 50%;
}
.tasks-task h1 {
  color: rgba(6, 6, 6, 0.75);
  font-size: 36px;
  width: 80%;
}
.tasks-item button {
  background-color: #8482c4;
  color: #ffffff;
  font-size: 20px;
  padding: 4px 35px;
  border-radius: 20px;
}
</style>

chrome

firefox

<块引用>

布局在 Google chrome 和 Microsoft Edge 中看起来很完美,但在 Mozilla firefox 上却不是,如图所示。这两个 div 在 Firefox 中附加。发生这种情况的原因是什么?我该如何解决这个问题?请帮我解决这个问题。提前致谢。

1 个答案:

答案 0 :(得分:0)

您必须首先使用 CSS 重置,使其在所有浏览器上看起来都相同,否则每个浏览器都会应用自己的默认样式。

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
<div class="tasks-container">
    <div class="tasks">
      <div class="tasks-item">
        <div class="tasks-task">
          <span class="label"></span>
          <h1>Lorem ipsum dolor sit amet conse pisicing elit</h1>
        </div>
        <button>abc</button>
      </div>
      <br />
      <div class="tasks-item">
        <div class="tasks-task">
          <span class="label"></span>
          <h1>Lorem ipsum dolor sit amet</h1>
        </div>
        <button>xyz</button>
      </div>
    </div>
  </div>
</template>

<style scoped>
.tasks-container {
  max-width: 1000px;
  margin: auto;
}
.tasks {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tasks-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f8f8;
  padding: 25px 30px;
}
.tasks-task {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 65%;
}
.tasks-task .label {
  width: 70px;
  height: 70px;
  background: #947777;
  border-radius: 50%;
}
.tasks-task h1 {
  color: rgba(6, 6, 6, 0.75);
  font-size: 36px;
  width: 80%;
}
.tasks-item button {
  background-color: #8482c4;
  color: #ffffff;
  font-size: 20px;
  padding: 4px 35px;
  border-radius: 20px;
}
</style>

应用此重置,然后应用样式,无论浏览器如何,它看起来都应该相同。

相关问题