- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家晚上好,我正在做一个投资组合页面,你需要根据窗口的大小在 vue.js 上调整 block 的大小。 enter image description here
图像中的图 block 应始终为正方形,并且在调整大小时它可以减小(到特定大小)或一行中的图 block 数量简单地改变。我不知道该怎么做
下面我将展示我完成的整个布局,也许它需要更改。我想马上澄清,我只懂网页设计,所以布局和代码本身可能并不完美
window.addEventListener('load', () => {
const loadPhoto = new Vue({
el: '#app',
data: {
photos:[
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
{name: 'photo1', url: 'assets/plate-photo/plate_one.jpg'},
{name: 'photo2', url: 'assets/plate-photo/plate_two.jpg'},
{name: 'photo3', url: 'assets/plate-photo/plate_three.jpg'},
{name: 'photo4', url: 'assets/plate-photo/plate_four.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_five.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_six.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_seven.jpg'},
{name: 'photo5', url: 'assets/plate-photo/plate_eate.jpg'},
{name: 'photo6', url: 'assets/plate-photo/plate_nine.jpg'},
{name: 'photo7', url: 'assets/plate-photo/plate_ten.jpg'},
]
},
});
});
@media (max-width: 500px) {
.nav-wrap {
display: none;
}
.nav-wrap .container {
opacity: 1;
}
}
* {
margin: 0;
padding: 0;
font-family: 'Work Sans', sans-serif;
user-select: none;
}
.content-padding {
padding-right: 20px;
}
.wrap-body {
display: flex;
}
.wrap-body .nav-wrap {
width: 400px;
height: 100vh;
background-color: #242b2e;
box-shadow: 0px 4px 20px #3d3d3d;
z-index: 100;
position: sticky;
top: 0;
left: 0;
}
.wrap-body .nav-wrap .logo-wrap {
padding-top: 15px;
padding-bottom: 15px;
display: flex;
justify-content: center;
background-color: #fff;
}
.wrap-body .nav-wrap .logo-wrap .logo .logo-svg {
width: 250px;
}
.wrap-body .nav-wrap .nav-main-wrap .main-title li {
text-align: right;
padding: 20px;
background: linear-gradient(#333b3f, #2f363a);
transition: .5s;
transition-delay: .4s;
-webkit-transition: .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
}
.wrap-body .nav-wrap .nav-main-wrap .main-title li a {
text-decoration: none;
text-transform: uppercase;
color: #fff;
font-weight: 400;
font-size: 18px;
}
.wrap-body .nav-wrap .nav-main-wrap .main-title li:hover {
background: none;
background-color: #2db8b7;
}
.wrap-body .nav-wrap .nav-main-wrap .main-title li:hover > a {
text-shadow: 0px 0px 10px #464646;
}
.wrap-body .nav-wrap .nav-main-wrap .main-title li:focus {
background-color: #30383c;
}
.wrap-body .nav-wrap .filter-wrap {
padding-top: 25px;
border-bottom: 1px solid #1e282b;
}
.wrap-body .nav-wrap .filter-wrap .filter-title {
text-align: right;
}
.wrap-body .nav-wrap .filter-wrap .filter-title .filter-title-text {
color: #2db8b7;
font-size: 18px;
}
.wrap-body .nav-wrap .filter-wrap .filter-title .filter-img {
width: 20px;
margin-left: 12px;
}
.wrap-body .nav-wrap .filter-wrap .filter-list {
margin-top: 25px;
margin-bottom: 25px;
}
.wrap-body .nav-wrap .filter-wrap .filter-list li {
margin-bottom: 15px;
text-align: right;
transform: .8s;
-webkit-transform: .8s;
-moz-transform: .8s;
-ms-transform: .8s;
-o-transform: .8s;
}
.wrap-body .nav-wrap .filter-wrap .filter-list li .filter-btn {
font-size: 14px;
color: #6b7072;
text-decoration: none;
background: none;
border: none;
outline: none;
}
.wrap-body .nav-wrap .filter-wrap .filter-list li .filter-btn:hover {
color: #929697;
}
.wrap-body .nav-wrap .filter-wrap .filter-list li .filter-btn:focus {
color: #ffffff;
text-transform: uppercase;
}
.wrap-body .nav-wrap .filter-wrap .filter-list li:last-child {
margin-bottom: 0;
}
.wrap-body .nav-wrap .nav-footer-wrap {
padding-top: 30px;
}
.wrap-body .nav-wrap .nav-footer-wrap .social-wrap {
display: flex;
justify-content: flex-end;
}
.wrap-body .nav-wrap .nav-footer-wrap .social-wrap .icon {
width: 25px;
height: 25px;
margin-left: 10px;
}
.wrap-body .nav-wrap .nav-footer-wrap .text-sub-footer {
text-align: right;
padding-top: 30px;
padding-bottom: 30px;
}
.wrap-body .nav-wrap .nav-footer-wrap .text-sub-footer .text-sub {
color: #929697;
font-size: 14px;
}
.wrap-body .main-wrap {
position: relative;
}
.wrap-body .main-wrap .info-tab {
display: flex;
flex-direction: column;
align-items: flex-end;
position: fixed;
top: 0;
right: 0;
z-index: 100;
}
.wrap-body .main-wrap .info-tab .info-btn {
width: 70px;
height: 70px;
padding: 4px;
background-color: #2db8b7;
border: none;
border-radius: 2px;
outline: none;
transition: .3s;
-webkit-transition: .3s;
-moz-transition: .3s;
-ms-transition: .3s;
-o-transition: .3s;
box-shadow: 0px -1px 3px #000000;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
-ms-border-radius: 2px;
-o-border-radius: 2px;
}
.wrap-body .main-wrap .info-tab .info-btn .btn-logo {
border: 1px solid #ffffff;
padding: 5px;
}
.wrap-body .main-wrap .info-tab .info-tab-wrap {
width: 100%;
height: 100%;
background-color: #1f1f1f;
padding: 10px;
opacity: 0;
}
.wrap-body .main-wrap .info-tab .info-tab-wrap .info-tab-list {
height: 25px;
margin: 10px;
display: flex;
}
.wrap-body .main-wrap .info-tab .info-tab-wrap .info-tab-list .info-tab-icon {
width: 25px;
height: 25px;
fill: #fff;
margin-right: 20px;
}
.wrap-body .main-wrap .info-tab .info-tab-wrap .info-tab-list .info-tab-text {
font-size: 14px;
color: #fff;
font-weight: 600;
}
.wrap-body .main-wrap .info-tab .info-btn:active + .info-tab-wrap {
opacity: 1;
}
.wrap-body .main-wrap .portfolio-wrap {
display: flex;
flex-wrap: wrap;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat {
width: 200px;
height: 200px;
position: relative;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .img {
width: 100%;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0 auto;
position: absolute;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: .2s;
-webkit-transition: .2s;
-moz-transition: .2s;
-ms-transition: .2s;
-o-transition: .2s;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-sup {
font-size: 1.2em;
color: #fff;
margin-bottom: 5px;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-sub {
font-size: 14px;
color: #fff;
margin-bottom: 10px;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-underline {
width: 140px;
height: 1px;
background-color: #fff;
margin-bottom: 10px;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-btn {
border: none;
background: none;
outline: none;
transition: .3s;
-webkit-transition: .3s;
-moz-transition: .3s;
-ms-transition: .3s;
-o-transition: .3s;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-btn .hover-title-right {
width: 15px;
height: 15px;
padding: 15px;
border: 1px solid #ffffff;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat .hover-title .hover-title-btn:focus > .hover-title-right {
border: 2px solid #ffffff;
}
.wrap-body .main-wrap .portfolio-wrap .wrapper-plat:hover > .hover-title {
background-color: rgba(45, 184, 183, 0.9);
opacity: 1;
-webkit-box-shadow: inset 0px 0px 17px -1px rgba(0, 0, 0, 0.49);
-moz-box-shadow: inset 0px 0px 17px -1px rgba(0, 0, 0, 0.49);
box-shadow: inset 0px 0px 17px -1px rgba(0, 0, 0, 0.49);
}
/*# sourceMappingURL=style.css.map */
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<!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">
<meta name="description" content="portfolio">
<meta name="keywords" content="HTML,CSS,XML,JavaScript,portfolio,girls,drugs">
<meta name="author" content="Eko Bilske">
<link rel="stylesheet" href="style/style.css">
<script src="scripts/main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<link href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700,900&display=swap" rel="stylesheet">
<title>Kappe For Creatives</title>
</head>
<body>
<section class="wrap-body">
<!--NAVIGATION-->
<section class="nav-wrap">
<!--logo wrap-->
<section class="logo-wrap">
<a href="index.html" class="logo">
<img src="assets/logo-01.svg" alt="logo site" class="logo-svg">
</a>
</section>
<!--/logo wrap-->
<!--main wrap-->
<section class="nav-main-wrap">
<ul class="main-title">
<li><a href="###">home</a></li>
<li><a href="###">work</a></li>
<li><a href="###">about</a></li>
<li><a href="###">blog</a></li>
<li><a href="###">services</a></li>
<li><a href="###">contact</a></li>
</ul>
</section>
<!--/main wrap-->
<!--filter wrap-->
<section class="filter-wrap">
<div class="filter-title content-padding">
<span class="filter-title-text">Filter</span>
<img src="assets/filter.svg" alt="filter img" class="filter-img">
</div>
<ul class="filter-list content-padding">
<li><button class="filter-btn">All works</button></li>
<li><button class="filter-btn">web-design</button></li>
<li><button class="filter-btn">illustration</button></li>
<li><button class="filter-btn">photography</button></li>
<li><button class="filter-btn">wallpapers</button></li>
<li><button class="filter-btn">brochures</button></li>
</ul>
</section>
<!--/filter wrap-->
<!--nav footer wrap-->
<section class="nav-footer-wrap content-padding">
<section class="social-wrap">
<a href="http://www.twiter.com" target="_blank">
<svg class="icon">
<use xlink:href="#linked"></use>
</svg>
</a>
<a href="http://www.google.com" target="_blank">
<svg class="icon">
<use xlink:href="#twitter"></use>
</svg>
</a>
<a href="http://www.twitter.com" target="_blank">
<svg class="icon">
<use xlink:href="#google"></use>
</svg>
</a>
<a href="http://www.flickr.com" target="_blank">
<svg class="icon">
<use xlink:href="#flickr"></use>
</svg>
</a>
<a href="http://www.facebook.com" target="_blank">
<svg class="icon">
<use xlink:href="#facebook"></use>
</svg>
</a>
</section>
<div class="text-sub-footer">
<span class="text-sub">©</span>
<script type="text/javascript">document.write(new Date().getFullYear());</script>
<span class="text-sub">Kappe, All Rights Reserved</span>
</div>
</section>
<!--/nav footer wrap-->
</section>
<!--/NAVIGATION-->
<!--PORTFOLIO PLATE-->
<section class="main-wrap">
<!--info-tab-->
<section class="info-tab">
<button class="info-btn">
<img src="assets/info-logo.png" alt="Info" class="btn-logo">
</button>
<section class="info-tab-wrap">
<div class="info-tab-list">
<svg class="info-tab-icon">
<use xlink:href="#phone"></use>
</svg>
<p class="info-tab-text">9930 1234 5679</p>
</div>
<div class="info-tab-list">
<svg class="info-tab-icon">
<use xlink:href="#send"></use>
</svg>
<p class="info-tab-text">contact@domain.com</p>
</div>
<div class="info-tab-list">
<svg class="info-tab-icon">
<use xlink:href="#home"></use>
</svg>
<p class="info-tab-text">street address example</p>
</div>
</section>
</section>
<!--/info-tab-->
<section class="portfolio-wrap" id="app">
<div class="wrapper-plat" v-for="photo in photos">
<div class="hover-title">
<div class="hover-title-sup">Cool App Design</div>
<div class="hover-title-sub">development, mobile</div>
<div class="hover-title-underline"></div>
<button class="hover-title-btn">
<img src="assets/right.png" alt="" class="hover-title-right">
</button>
</div>
<img :src="photo.url" class="img">
</div>
</section>
</section>
<!--/PORTFOLIO PLATE-->
</section>
</body>
</html>
最佳答案
据我了解,您想制作响应式方形 div,对吗?
一种简单的方法是使用视口(viewport)宽度 (vw
) 值调整 div 的大小。您可以在下面的 .cat
div 的高度和宽度值上看到它的使用。
.wrapper{
display:flex;
}
.cat {
height: 25vw;
width: 25vw;
background-image: url("https://media.wired.com/photos/5cdefc28b2569892c06b2ae4/master/w_2560%2Cc_limit/Culture-Grumpy-Cat-487386121-2.jpg");
background-size: cover;
background-position: center;
}
<div class="wrapper">
<div class="cat"></div>
<div class="cat"></div>
<div class="cat"></div>
<div class="cat"></div>
</div>
还有其他方法,但我认为这个方法非常简单。您可能会在这里找到有用的信息:How to style a div to be a responsive square?
关于javascript - 响应式图库 Vue.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59079730/
我刚刚更新了 Ruby,现在我在尝试启动 compass 时遇到以下错误: Encoding::CompatibilityError on line ["28"] of /usr/local/Cell
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在尝试在我的 iOS 应用程序中开发可折叠/ Accordion 式的功能。这将是您可以在网站上找到的典型 FAQ 类型功能。我想点击标题,然后显示详细信息。 因为这是帮助部分,只有几个项目,我认
我正在尝试设计一个基于 REST 的 Web 服务来与我正在开发的农场动物管理系统进行交互。 为了详细说明问题,我收藏了动物 属于一个农场。每只动物都有自己的信息——例如姓名、身份证号、品种年龄等。因
我有 3 种不同的表单,其中复选框数量不同,每个部分基本上代表一个表单,因此当用户选择该部分中的复选框时,它会显示他们在该部分的总金额中 checkout 了多少 HTML
我有一份 32 页的 PDF 版家谱。与其将家谱全部放在一个非常大的 PDF 页面上(这是我想要的),不如将其格式化为一组 8 个单独的美国信纸大小的页面应该在整个宽度上缝合; 4 行这样就完成了树。
指SASS implementation for Java? : 在 Maven 目标编译包中自动编译 compass-style.org 样式表的最佳方法是什么? 我不想发送太多的自编译库,也不想通
鉴于以下 XAML... 我正在寻找一种绑定(bind) ComboBox、Button 和 Command 的方法,以便当 ComboBox 的值更改时,在 Command 上调用 CanExe
在玩具应用程序中,我有一个显示所有帖子标题的“帖子”模板。当您单击每个标题时,我不想直接进入“显示” View ,而是直接内联展开该帖子的其余内容。 我考虑过让 postRoute 重用 postsR
我需要一些使用 Twitter Bootstrap 或其他响应式框架的自定义 Swagger-UI 实现。需要在我的移动设备上使用这样的 UI 测试我的 API,但 swagger-ui 不能很好地扩
我正在做一个项目,我真的在尝试编写面向对象的 JavaScript 代码。我刚刚开始阅读Douglas Crockford's JavaScript: The Good Parts我很快开始意识到用
在 C# 中,我通过执行以下操作来加密文本数据(请注意我正在以 block ( block )的形式加密数据): public string EncryptData(string pu
我正在构建一个社交网站,该网站将向全世界公开 REST API (WCF WebAPI),以便任何开发人员都能够为该网站创建客户端应用程序、将其与其他服务集成等。 我想为 API 实现 Faceboo
我是一名优秀的程序员,十分优秀!