让电影卡响应

时间:2018-06-04 19:21:46

标签: html css responsive-design responsive responsiveness

Hello Stackoverflow社区,

我想让我的电影卡响应但是我有麻烦......我根本不知道从哪里开始让它响应。我需要哪些css属性等问题等等......

我希望卡片具有响应性,因为它必须在多个设备上方便用户使用。

(请注意,我不想使用bootstrap)

问候Steve Bergosso,

这是我的源代码:



* {
  box-sizing: border-box;
}

.cover {
  width: 220px;
  margin-bottom: 10px;
  margin-left: 5px;
  margin-right: 5px;
  display: inline-block;
  height: 333px;
  overflow: hidden;
  box-shadow: 0px 4px 10px 1px rgba(0, 0, 0, 0.55);
  position: relative;
  border: 4px solid rgba(0, 0, 0, 0.33);
  background: #333
}

.cover img {
  width: 100%;
  height: 100%;
  transition: .3s all ease;
}

.cover:hover img {
  transform: translate(0px, 38px);
  filter: blur(3px);
}

.cover .header {
  position: absolute;
  box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.44);
  width: 100%;
  top: -130px;
  transition: .3s all ease;
}

.cover .header .type {
  float: center;
  background-color: #333;
  color: #fff;
  padding: -40px 15px;
    margin-top: -10px;
}

.cover .header .seen {
  float: right;
  background-color: black;
  color: #fff;
  padding: 10px 30px;
}

.cover:hover .header {
  top: 0
}

.cover .info {
  position: absolute;
  color: #fff;
  margin-top: 67px;
  text-align: center;
  z-index: 9999;
  bottom: -250px;
  transition: 0.5s;
}

.cover .info h3 {
  font-weight: bold;
}

.cover .info button {
  border: 0;
  padding: 13px;
  width: 100%;
  color: #fff;
  background: #a5292d;
  font-size: 19px;
}
.cover:hover .info{
  bottom:0;
}

@media only screen and (max-width:1280px) {}

@media only screen and (max-width:1024px) {}

@media only screen and (max-width:768px) {}

@media only screen and (max-width:480px) {}

@media only screen and (max-width:320px) {}


/*GRID*/

* {
    box-sizing: border-box;
}

.row::after {
    content: "";
    clear: both;
    display: table;
}

[class*="col-"] {
    float: left;
    padding: 15px;
}

.col-1 {
    width: 8.33%;
}

.col-2 {
    width: 20.00%;
}

.col-3 {
    width: 25%;
}

.col-4 {
    width: 33.33%;
}

.col-5 {
    width: 41.66%;
}

.col-6 {
    width: 50%;
}

.col-7 {
    width: 58.33%;
}

.col-8 {
    width: 66.66%;
}

.col-9 {
    width: 75%;
}

.col-10 {
    width: 83.33%;
}

.col-11 {
    width: 91.66%;
}

.col-12 {
    width: 100%;
}

.films {
    padding-left: 150px;
    padding-right: 150px;
}

<div class="col-2">
<div class="cover">
  <div class="header">
    <div class="seen"><span class="glyphicon glyphicon-eye-open"></span> 1350</div>

    <div class="type">Action</div>
  </div>
  <div class="info">
    <h3>inferno (2016)</h3>
    <p>When Robert Langdon wakes up in an Italian hospital with amnesia, he teams up with Dr. Sienna Brooks, and together they must race across Europe against the clock to foil a deadly global plot.</p>
    <button>Movies</button>
  </div>
  <img src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTUzNTE2NTkzMV5BMl5BanBnXkFtZTgwMDAzOTUyMDI@._V1_SY1000_CR0,0,674,1000_AL_.jpg">

</div>

<!--______________________________-->
<div class="cover">
  <div class="header">
    <div class="seen"><span class="glyphicon glyphicon-eye-open"></span> 1210</div>

    <div class="type">Action</div>
  </div>
  <div class="info">
    <h3>Apocalypse (2016)</h3>
    <p>When Robert Langdon wakes up in an Italian hospital with amnesia, he teams up with Dr. Sienna Brooks, and together they must race across Europe against the clock to foil a deadly global plot.</p>
    <button>Movies</button>
  </div>
  <img src="https://images-na.ssl-images-amazon.com/images/M/MV5BMjU1ODM1MzYxN15BMl5BanBnXkFtZTgwOTA4NDE2ODE@._V1_UY1200_CR91,0,630,1200_AL_.jpg">

</div>



<!--______________________________-->
<div class="cover">
  <div class="header">
    <div class="seen"><span class="glyphicon glyphicon-eye-open"></span> 1210</div>

    <div class="type">Action</div>
  </div>
  <div class="info">
    <h3>Iron man (2016)</h3>
    <p>When Robert Langdon wakes up in an Italian hospital with amnesia, he teams up with Dr. Sienna Brooks, and together they must race across Europe against the clock to foil a deadly global plot.</p>
    <button>Movies</button>
  </div>
  <img src="https://upload.wikimedia.org/wikipedia/en/d/d5/Iron_Man_3_theatrical_poster.jpg">

</div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

&#39;响应&#39;这是一个相当广泛的术语,虽然我认为你的意思是根据屏幕尺寸设置不同尺寸的卡片。谷歌就此发表了really good guide,这绝对值得一试 然而,基本概念非常简单:CSS,实际上,支持@media,其中包括仅在屏幕具有您定义的大小时才将某种样式应用于元素。例如,

@media (min-width: 100px) {
    .cover {
        /* something */
    }
}

如果屏幕宽度超过100px,那么只会将something样式应用于卡片(顺便提一下,这很常见)。其他受支持的条件包括max-widthwidthmin-heightheightmax-heightscreen(基本上只检查是否有&#39; sa屏幕,因为printspeech几乎已被弃用。它支持标准的bool运算符,例如andor

我希望这是你的意思,响应:)