css - 布局在 Google Chrome 上看起来很完美,但在 Mozilla Firefox 上却不行
问题描述
索引.vue
<template>
<div>
<Tasks />
</div>
</template>
任务.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>
如图所示,该布局在 Google chrome 和 Microsoft edge 中看起来很完美,但在 Mozilla firefox 上却不完美。这两个 div 附加在 Firefox 中。发生这种情况的原因是什么?我该如何解决这个问题?请帮我解决这个问题。先感谢您。
解决方案
您必须首先使用 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>
应用此重置,然后应用样式,无论浏览器如何,它都应该看起来相同。
推荐阅读
- laravel - 我无法通过 laravel 中的 id 找到订单
- javascript - 使用 Javascript 为谷歌图表传递列号
- python - 检测单词然后发送嵌入消息 (discord.py)
- sql - 使用 CTE 确定家庭成员的特定层次 ID
- javascript - 为什么我的 js 函数在脚本标签内工作,为什么不在外部 javascript 文件 django 表单中工作
- flask - NLP Flask 应用程序启动节点在 Google Kubernetes GKE 上超时
- c# - 将同一对象添加到不同列表时,C# 中的内存使用如何工作?
- r - 参与者如何使用 tidyverse 将第一行中的值应用于所有后续行
- javascript - 表单输入验证后的 JavaScript 重定向页面
- odoo - 如何添加 _sql_constraints 以检查 odoo 中的 char 字段长度?