簡體   English   中英

如何通過更改它們的編號使所有 div 標簽響應。 列數

[英]How to make All div tags responsive by changing their no. of colums

我創建了一個簡單的網頁,但是當我在移動設備上打開一個網頁時,它看起來很丑,所有的 div 容器看起來都很大。 所以我想要的改變是當我在移動設備上打開這個網頁時,列數應該減少到 3 並且沒有。 行數應相應增加。 我知道我需要使用媒體查詢,但我不知道如何減少 no。 的列。 我嘗試了很多次,但是當我減少它時,所有容器都重疊了。

 * { margin: 0px; padding: 0px; } body { background-color: #485461; background-image: linear-gradient(315deg, #485461 0%, #28313b 74%); font-family: 'RobotoDraft', 'Roboto', sans-serif; -webkit-font-smoothing: antialiased; } * { -webkit-box-sizing: border-box; box-sizing: border-box; } h5 { margin: 0px; font-size: 1.4em; font-weight: 700; } p { font-size: 12px; }.center { height: 75vh; width: 100%; display: flex; justify-content: center; align-items: center; } /* End Non-Essential */ #video, #vd, #vd1, #vd4, #vd5, #vd6, #vd7, #vd8 { height: 18em; width: 14em; display: none; object-fit: cover }.property-card { margin: 5px; height: 18em; width: 14em; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; position: relative; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); border-radius: 16px; overflow: hidden; -webkit-box-shadow: 15px 15px 27px #e1e1e3, -15px -15px 27px #ffffff; box-shadow: 15px 15px 27px #e1e1e3, -15px -15px 27px #ffffff; } /* ^-- The margin bottom is necessary for the drop shadow otherwise it gets clipped in certain cases. */ /* Top Half of card, image. */.property-image { height: 15em; width: 14em; padding: 1em 2em; position: Absolute; top: 0px; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); background-image: url('https://cdn.photographylife.com/wp-content/uploads/2017/01/What-is-landscape-photography.jpg'); background-size: cover; background-repeat: no-repeat; } /* Bottom Card Section */.property-description { background-color: #FAFAFC; height: 5em; width: 14em; position: absolute; bottom: 0em; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); padding: 0.5em 1em; text-align: center; } /* Social Icons */.property-social-icons { width: 1em; height: 1em; background-color: black; position: absolute; bottom: 1em; left: 1em; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); } /* Property Cards Hover States */.property-card:hover.property-description { height: 0em; padding: 0px 1em; }.property-card:hover.property-image { background-size: cover; }.property-card:hover.property-social-icons { background-color: white; }.property-card:hover.property-social-icons:hover { background-color: transparent; } @media (min-width: 600px) { }
 <div class="center"> <div class="property-card" id="property-card"> <div onmousedown="f1()" class="property-image" id="image"> <div class="property-image-title"></div> </div> <video id="video" width="640" height="480" controls> <source src="saiyaan-video.mp4"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div onmousedown="f2()" class="property-image" id="ig"> <div class="property-image-title"></div> </div> <video id="vd" width="640" height="480" controls> <source src="Te amo.mp4"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div onmouseover="f3()" class="property-image" id="ig1"> <div class="property-image-title"></div> </div> <video id="vd1"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div onmouseover="f7()" class="property-image" id="ig7"> <div class="property-image-title"></div> </div> <video id="vd7"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> </div> <div class="center"> <div class="property-card"> <a href="#"> <div onmouseover="f4()" class="property-image" id="ig4"> <div class="property-image-title"></div> </div> <video id="vd4"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div onmouseover="f5()" class="property-image" id="ig5"> <div class="property-image-title"></div> </div> <video id="vd5"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div onmouseover="f6()" class="property-image" id="ig6"> <div class="property-image-title"></div> </div> <video id="vd6"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div onmouseover="f8()" class="property-image" id="ig8"> <div class="property-image-title"></div> </div> <video id="vd8"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> </div>

嘗試添加flex-wrap: wrap; 到父級,以便卡片在空間不足時流到下一行。 您還必須刪除height: 75vh; 從容器中防止它們重疊:

 * { margin: 0px; padding: 0px; } body { background-color: #485461; background-image: linear-gradient(315deg, #485461 0%, #28313b 74%); font-family: 'RobotoDraft', 'Roboto', sans-serif; -webkit-font-smoothing: antialiased; } * { -webkit-box-sizing: border-box; box-sizing: border-box; } h5 { margin: 0px; font-size: 1.4em; font-weight: 700; } p { font-size: 12px; }.center { width: 100%; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; } /* End Non-Essential */ #video, #vd, #vd1, #vd4, #vd5, #vd6, #vd7, #vd8 { height: 18em; width: 14em; display: none; object-fit: cover }.property-card { margin: 5px; height: 18em; width: 14em; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; position: relative; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); border-radius: 16px; overflow: hidden; -webkit-box-shadow: 15px 15px 27px #e1e1e3, -15px -15px 27px #ffffff; box-shadow: 15px 15px 27px #e1e1e3, -15px -15px 27px #ffffff; } /* ^-- The margin bottom is necessary for the drop shadow otherwise it gets clipped in certain cases. */ /* Top Half of card, image. */.property-image { height: 15em; width: 14em; padding: 1em 2em; position: Absolute; top: 0px; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); background-image: url('https://cdn.photographylife.com/wp-content/uploads/2017/01/What-is-landscape-photography.jpg'); background-size: cover; background-repeat: no-repeat; } /* Bottom Card Section */.property-description { background-color: #FAFAFC; height: 5em; width: 14em; position: absolute; bottom: 0em; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); padding: 0.5em 1em; text-align: center; } /* Social Icons */.property-social-icons { width: 1em; height: 1em; background-color: black; position: absolute; bottom: 1em; left: 1em; -webkit-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); -o-transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.4s cubic-bezier(0.645, 0.045, 0.355, 1); } /* Property Cards Hover States */.property-card:hover.property-description { height: 0em; padding: 0px 1em; }.property-card:hover.property-image { background-size: cover; }.property-card:hover.property-social-icons { background-color: white; }.property-card:hover.property-social-icons:hover { background-color: transparent; } @media (min-width: 600px) {}
 <div class="center"> <div class="property-card" id="property-card"> <div class="property-image" id="image"> <div class="property-image-title"></div> </div> <video id="video" width="640" height="480" controls> <source src="saiyaan-video.mp4"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div class="property-image" id="ig"> <div class="property-image-title"></div> </div> <video id="vd" width="640" height="480" controls> <source src="Te amo.mp4"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div class="property-image" id="ig1"> <div class="property-image-title"></div> </div> <video id="vd1"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <div class="property-image" id="ig7"> <div class="property-image-title"></div> </div> <video id="vd7"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> </div> <div class="center"> <div class="property-card"> <a href="#"> <div class="property-image" id="ig4"> <div class="property-image-title"></div> </div> <video id="vd4"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div class="property-image" id="ig5"> <div class="property-image-title"></div> </div> <video id="vd5"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div class="property-image" id="ig6"> <div class="property-image-title"></div> </div> <video id="vd6"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> <div class="property-card"> <a href="#"> <div class="property-image" id="ig8"> <div class="property-image-title"></div> </div> <video id="vd8"> <source control src="Pexels Videos 2795749.mp4" type="video/webm"> </video> </a> <div class="property-description"> <h5> Card Title </h5> <p>Lorem Ipsum Dipsum hortata. Mixcall Horcho. Mixwell Chingo. More Bingo. Lorem Ipum doth be hard.</p> </div> </div> </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM