我正在使用flexbox创建一个简单的电影卡布局,但是我的css在Chrome中无法像在Firefox中一样呈现出问题。
* {
margin: 0;
heading: 0;
box-sizing: border-box;
font-family: san-serif;
font-weight: 400;
font-size: 25px;
color: black;
}
.movie-list__container {
padding: 10px;
display: flex;
flex-direction: column;
}
.movie-card__item {
box-shadow: 0 10px 3px rgba(0,0,0,0.12), 0 5px 2px rgba(0,0,0,0.24);
margin: 20px;
color: #fff;
font-size: 40px;
border-radius: 25px;
background-color: white;
display: flex;
flex: 1;
flex-direction: column;
}
.movie-card__content {
margin: 0 10px;
display: flex;
flex-direction: row;
}
.movie-card__options {
background-color: #e0e0e0;
padding: 20px;
border-radius: 0 0 15px 15px;
}
.movie-card__left {
margin: 10px;
flex: 0 1 155px;
display: flex;
flex-direction: column;
display: flex;
}
.movie-card__right {
margin: 10px;
flex: 1 1;
display: flex;
flex-direction: column;
}
.movie-card__poster {
margin: 5px;
}
.movie-card__poster > img {
box-shadow: 0 2px 5px rgba(0,0,0,0.12);
border-radius: 10px;
}
.movie-card__date {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__runtime {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__genre {
padding-top: 5px;
}
.genre-item {
border-radius: 8px;
font-size: 12px;
margin: 2px;
padding: 5px;
color: #FFF;
background-color: #263137;
display: inline-block;
}
.movie-card__controls {
margin: 20px;
width: 40px;
align-self: flex-end;
}
.moive-card__header {
flex: 0 0;
display: flex;
}
.movie_card__title {
margin: 5px;
font-size: 50px;
}
.movie_card__mpaa-rating {
margin: 5px;
}
<main>
<div class="movie-list__container">
<div class="movie-card__item">
<div class="movie-card__controls">
...
</div>
<div class="movie-card__content">
<div class="movie-card__left">
<div class="movie-card__poster">
<img src="https://image.tmdb.org/t/p/w154//x1txcDXkcM65gl7w20PwYSxAYah.jpg" />
</div>
<div class="movie-card__runtime">
95 minutes
</div>
<div class="movie-card__date">
June 06 2018
</div>
<div class="movie-card__genre">
<span class="genre-item">Horror</span>
<span class="genre-item">Comedy</span>
<span class="genre-item">Action</span>
<span class="genre-item">Drama</span>
<span class="genre-item">Adventure</span>
</div>
</div>
<div class="movie-card__right">
<div class="moive-card__header">
<div class="movie_card__title">
The Incredibles 2
</div>
<div class="movie_card__mpaa-rating">
PG
</div>
</div>
<div class="movie-card__overview">
A family of undercover superheroes, while trying to live the quiet suburban life, are forced into action to save the world.
</div>
</div>
</div>
<div class="movie-card__options">
</div>
</div>
</div>
</main>
答案 0 :(得分:1)
Try this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
* {
margin: 0;
heading: 0;
box-sizing: border-box;
font-family: san-serif;
font-weight: 400;
font-size: 25px;
color: black;
}
.movie-list__container {
padding: 10px;
display: flex;
flex-direction: column;
}
.movie-card__item {
box-shadow: 0 10px 3px rgba(0,0,0,0.12), 0 5px 2px rgba(0,0,0,0.24);
margin: 20px;
color: #fff;
font-size: 40px;
border-radius: 25px;
background-color: white;
display: flex;
flex: 1;
flex-direction: column;
}
.movie-card__content {
margin: 0 10px;
display: flex;
flex-direction: row;
}
.movie-card__options {
background-color: #e0e0e0;
padding: 20px;
border-radius: 0 0 15px 15px;
}
.movie-card__left {
margin: 10px;
flex: 0 1 155px;
display: flex;
flex-direction: column;
display: flex;
}
.movie-card__right {
margin: 10px;
flex: 1 1;
display: flex;
flex-direction: column;
}
.movie-card__poster {
margin: 5px;
}
.movie-card__poster > img {
box-shadow: 0 2px 5px rgba(0,0,0,0.12);
border-radius: 10px;
}
.movie-card__date {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__runtime {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__genre {
padding-top: 5px;
}
.genre-item {
border-radius: 8px;
font-size: 12px;
margin: 2px;
padding: 5px;
color: #FFF;
background-color: #263137;
display: inline-block;
}
.movie-card__controls {
margin: 20px;
width: 40px;
align-self: flex-end;
}
.moive-card__header {
display: flex;
}
.movie_card__title {
margin: 5px;
font-size: 50px;
}
.movie_card__mpaa-rating {
margin: 5px;
}
</style>
<body>
<main>
<div class="movie-list__container">
<div class="movie-card__item">
<div class="movie-card__controls">
...
</div>
<div class="movie-card__content">
<div class="movie-card__left">
<div class="movie-card__poster">
<img src="https://image.tmdb.org/t/p/w154//x1txcDXkcM65gl7w20PwYSxAYah.jpg" />
</div>
<div class="movie-card__runtime">
95 minutes
</div>
<div class="movie-card__date">
June 06 2018
</div>
<div class="movie-card__genre">
<span class="genre-item">Horror</span>
<span class="genre-item">Comedy</span>
<span class="genre-item">Action</span>
<span class="genre-item">Drama</span>
<span class="genre-item">Adventure</span>
</div>
</div>
<div class="movie-card__right">
<div class="moive-card__header">
<div class="movie_card__title">
The Incredibles 2
</div>
<div class="movie_card__mpaa-rating">
PG
</div>
</div>
<div class="movie-card__overview">
A family of undercover superheroes, while trying to live the quiet suburban life, are forced into action to save the world.
</div>
</div>
</div>
<div class="movie-card__options">
</div>
</div>
</div>
</main>
</body>
</html>
答案 1 :(得分:0)
从flex: 0 0;
删除.moive-card__header
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: san-serif;
font-weight: 400;
font-size: 25px;
color: black;
}
.movie-list__container {
padding: 10px;
display: flex;
flex-direction: column;
}
.movie-card__item {
box-shadow: 0 10px 3px rgba(0, 0, 0, 0.12), 0 5px 2px rgba(0, 0, 0, 0.24);
margin: 20px;
color: #fff;
font-size: 40px;
border-radius: 25px;
background-color: white;
display: flex;
flex: 1;
flex-direction: column;
}
.movie-card__content {
margin: 0 10px;
display: flex;
flex-direction: row;
}
.movie-card__options {
background-color: #e0e0e0;
padding: 20px;
border-radius: 0 0 15px 15px;
}
.movie-card__left {
margin: 10px;
flex: 0 1 155px;
display: flex;
flex-direction: column;
display: flex;
}
.movie-card__right {
margin: 10px;
flex: 1 1;
display: flex;
flex-direction: column;
}
.movie-card__poster {
margin: 5px;
}
.movie-card__poster>img {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
border-radius: 10px;
}
.movie-card__date {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__runtime {
font-size: 15px;
padding: 2px 10px;
}
.movie-card__genre {
padding-top: 5px;
}
.genre-item {
border-radius: 8px;
font-size: 12px;
margin: 2px;
padding: 5px;
color: #FFF;
background-color: #263137;
display: inline-block;
}
.movie-card__controls {
margin: 20px;
width: 40px;
align-self: flex-end;
}
.moive-card__header {
display: flex;
}
.movie_card__title {
margin: 5px;
font-size: 50px;
}
.movie_card__mpaa-rating {
margin: 5px;
}
<main>
<div class="movie-list__container">
<div class="movie-card__item">
<div class="movie-card__controls">
...
</div>
<div class="movie-card__content">
<div class="movie-card__left">
<div class="movie-card__poster">
<img src="https://image.tmdb.org/t/p/w154//x1txcDXkcM65gl7w20PwYSxAYah.jpg" />
</div>
<div class="movie-card__runtime">
95 minutes
</div>
<div class="movie-card__date">
June 06 2018
</div>
<div class="movie-card__genre">
<span class="genre-item">Horror</span>
<span class="genre-item">Comedy</span>
<span class="genre-item">Action</span>
<span class="genre-item">Drama</span>
<span class="genre-item">Adventure</span>
</div>
</div>
<div class="movie-card__right">
<div class="moive-card__header">
<div class="movie_card__title">
The Incredibles 2
</div>
<div class="movie_card__mpaa-rating">
PG
</div>
</div>
<div class="movie-card__overview">
A family of undercover superheroes, while trying to live the quiet suburban life, are forced into action to save the world.
</div>
</div>
</div>
<div class="movie-card__options">
</div>
</div>
</div>
</main>