大家好!
所以我最近完成了我的第一个网站,但是由于某些屏幕尺寸存在一些兼容性问题,因此我正在忙于对其进行抛光。我无法弄清或解决一件事,那就是在我的团队页面中,如果您通过移动视图(通过移动或chrome开发工具)查看它,您会注意到我的容器忽略了我的横幅和导航栏。这导致页面底部的巨大空间。我想到的唯一解决方案可能是为容器创建页边距上限,但这会导致大量媒体查询。也许是有一个原因会导致它不予理or还是更好的解决方案?
谢谢!
HTML:
<html lang="en">
<head>
<!-- Title of Page -->
<title> Teams - Severe Gaming </title>
<!-- Bootstrap CDN and requirements -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Custom CSS -->
<link rel="shorcut icon" type="image/png" href="/static/images/favicon.png" />
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/teams.css"/>
<script src="/static/scripts/teams.js"></script>
<meta charset="UTF-8">
<title> Severe Gaming </title>
</head>
<body>
<!--Main Navigation bar-->
<nav class="navbar navbar-expand-lg">
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav ml-auto">
<a class="nav-item nav-link" href="/">Home</a>
<a class="nav-item nav-link" href="/news/">News</a>
<a class="nav-item nav-link" href="/teams/">Teams</a>
<a class="nav-item nav-link" href="/matches/">Matches</a>
<a class="nav-item nav-link" href="/media/">Media</a>
<a class="nav-item nav-link" href="/sponsors/">Sponsors</a>
<a class="nav-item nav-link" href="/contact/">Contact Us</a>
</div>
</div>
</nav>
<!-- Main Banner -->
<div class="banner"></div>
<!-- User Controls -->
<!-- Main Body Container -->
<!-- Top Container -->
<div class="container-fluid">
<!--- DOTA 2 -->
<section class="strips">
<article class="strips__strip">
<div class="strip__content">
<h1 class="strip__title" data-name="Lorem"></h1>
<div class="strip__inner-text">
<div class="blackback">
<h2>SEVERE DOTA 2</h2>
<!--- DOTA 2 TEAM INFO -->
<div class="row justify-content-center">
<div class="col-sm-2">
<img src="/media/PPdefault.jpg" class="contain"/>
<h3>Lorin "Sil" Bohm</h3>
<p>Position: </p>
</div>
<div class="col-sm-2">
<img src="/media/PPdefault.jpg" class="contain"/>
<h3>Michael "AcidMan" Davis</h3>
<p>Position: </p>
</div>
<div class="col-sm-2">
<img src="/media/PPdefault.jpg" class="contain"/>
<h3>Ryan "Psuedo" Roux</h3>
<p>Position: </p>
</div>
<div class="col-sm-2">
<img src="/media/PPdefault.jpg" class="contain"/>
<h3>Nicholas "Ench" Weyer</h3>
<p>Position: </p>
</div>
<div class="col-sm-2">
<img src="/media/PPdefault.jpg" class="contain"/>
<h3>Martin "VivAZ" Buxmann</h3>
<p>Position: </p>
</div>
</div>
</div>
</div>
</div>
</article>
<!--- CSGO -->
<article class="strips__strip">
<div class="strip__content">
<h1 class="strip__title" data-name="Ipsum"></h1>
<div class="strip__inner-text">
<div class="blackback">
<h2>Counter-Strike: Global Offensive</h2>
<!--- CSGO TEAM INFO -->
<div class="row justify-content-center">
<div class="lookingforteam"> We are currently looking for a Counter-Strike team to play for us! If interested use the contact form located on the website to contact us!</div>
</div>
</div>
</div>
</div>
</article>
<!--- Hearthstone -->
<article class="strips__strip">
<div class="strip__content">
<h1 class="strip__title" data-name="Ipsum"></h1>
<div class="strip__inner-text">
<div class="blackback">
<h2>Hearthstone</h2>
<!--- Hearthstone TEAM INFO -->
<div class="row justify-content-center">
<div class="lookingforteam"> We are currently looking for Hearthstone players to play for us! If interested use the contact form located on the website to contact us!</div>
</div>
</div>
</div>
</div>
</article>
<!--- LoL -->
<article class="strips__strip">
<div class="strip__content">
<h1 class="strip__title" data-name="Ipsum"></h1>
<div class="strip__inner-text">
<div class="blackback">
<h2>League of Legends</h2>
<!--- LoL TEAM INFO -->
<div class="row justify-content-center">
<div class="lookingforteam"> We are currently looking for a League Of Legends team to play for us! If interested use the contact form located on the website to contact us!</div>
</div>
</div>
</div>
</div>
</article>
<!--- Rocket League -->
<article class="strips__strip">
<div class="strip__content">
<h1 class="strip__title" data-name="Ipsum"></h1>
<div class="strip__inner-text">
<div class="blackback">
<h2>Rocket League</h2>
<!--- Rocket League TEAM INFO -->
<div class="row justify-content-center">
<div class="lookingforteam"> We are currently looking for a Rocket League team to play for us! If interested use the contact form located on the website to contact us!</div>
</div>
</div>
</div>
</div>
</article>
<i class="fas fa-chevron-circle-left strip__close"></i>
<i class="fa fa-chevron-circle-right strip__close"></i>
</section>
</div>
<!-- Footer -->
<div class="footer"></div>
</body>
</html>
有两个CSS文件。一个基于基本模板,即style.css,该模板在每个页面中呈现,然后是唯一的css,即teams.css:
style.css
/* Main HTML */
* {
margin: 0;
color: white;
}
html {
font-family: Roboto, elvetica, Arial, sans-serif;
}
body {
background-color: #0b0e17;
}
/* Navigation Bar*/
a {
color: #ffffff;
}
a:hover {
opacity: 0.3;
background: url("/static/images/menu-glass.png");
color: #ffffff;
}
.navbar{
top: 0;
font-weight: 700;
height: 90px;
width: 100%;
z-index:21;
position: fixed;
text-transform: uppercase;
background: url("/static/images/nav-bar.png");
background-position: center;
box-shadow: 0px 10px 23px -2px rgba(0,0,0,0.8);
}
.navbar-collapse{
margin-top:10px;
background-color: rgba(11,14,23, 0.7);
}
.nav-item {
text-align: center;
font-size: 1rem;
}
.nav-item:hover{
opacity: 1;
background: rgb(11,14,23);
}
/* Collapsed Hamburger Custom Settings */
.navbar-toggler {
width: 50px;
height: 40px;
background-color: #fff;
border:none;
}
.navbar-toggler .line{
width: 100%;
float: left;
height: 2px;
background-color: #000;
margin-bottom: 5px;
}
/* Banner */
.banner {
margin-top: 90px;
background: url("/static/images/banner.png");
background-position: center;
background-repeat: no-repeat;
height: 392px;
}
/* Control Center */
.buttons{
padding-top: 20px;
}
.btn-link{
background: none;
border: none;
cursor: pointer;
font-size: 1rem;
color:white;
text-decoration: none;
}
.highlight{
font-size: 1rem;
}
div.user-controls-container{
width:100%;
height:70px;
text-align: right;
}
.inline{
display:inline;
margin-right: 50px;
margin-left: 50px;
}
/* Footer */
.footer {
bottom:0;
background: url("/static/images/footer.png");
background-size: cover;
background-position: center;
height: 40px;
z-index: 100;
}
teams.css
.container-fluid{
padding:0 !important;
}
.strips {
height: 90vh;
text-align: center;
overflow: hidden;
color: white;
}
.strips__strip {
will-change: width, left, z-index, height;
position: absolute;
width: 20%;
height: 90vh;
overflow: hidden;
cursor: pointer;
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.strips__strip:nth-child(1) {
left: 0%;
}
.strips__strip:nth-child(2) {
left: 20%;
}
.strips__strip:nth-child(3) {
left: 40%;
}
.strips__strip:nth-child(4) {
left: 60%;
}
.strips__strip:nth-child(5) {
left: 80%;
}
.strips__strip:nth-child(1) .strip__content {
background-image: url("/static/images/dota2-teams.jpg");
background-position: center;
background-size: cover;
transform: translate3d(-100%, 0, 0);
animation-name: strip1;
animation-delay: 0.1s;
}
.strips__strip:nth-child(2) .strip__content {
background-image: url("/static/images/csgo-teams.jpg");
background-position: center;
background-size: cover;
transform: translate3d(0, 100%, 0);
animation-name: strip2;
animation-delay: 0.2s;
}
.strips__strip:nth-child(3) .strip__content {
background-image: url("/static/images/hearthstone-teams.jpg");
background-position: center;
background-size: cover;
transform: translate3d(0, -100%, 0);
animation-name: strip3;
animation-delay: 0.3s;
}
.strips__strip:nth-child(4) .strip__content {
background-image: url("/static/images/lol-teams.jpg");
background-position: center;
background-size: cover;
transform: translate3d(0, 100%, 0);
animation-name: strip4;
animation-delay: 0.4s;
}
.strips__strip:nth-child(5) .strip__content {
background-image: url("/static/images/rocket-teams.jpg");
background-position: center;
background-size: cover;
transform: translate3d(100%, 0, 0);
animation-name: strip5;
animation-delay: 0.5s;
}
@media screen and (max-width: 760px) {
.strips__strip {
max-height: 20vh;
}
.strips__strip:nth-child(1) {
top: 0;
left: 0;
width: 100%;
}
.strips__strip:nth-child(2) {
top: 20vh;
left: 0;
width: 100%;
}
.strips__strip:nth-child(3) {
top: 40vh;
left: 0;
width: 100%;
}
.strips__strip:nth-child(4) {
top: 60vh;
left: 0;
width: 100%;
}
.strips__strip:nth-child(5) {
top: 80vh;
left: 0;
width: 100%;
}
}
.strips .strip__content {
animation-duration: 1s;
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
animation-fill-mode: both;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-decoration: none;
}
.strips .strip__content:hover:before {
transform: skew(-30deg) scale(3) translate(0, 0);
opacity: 0.1;
}
.strips .strip__content:before {
content: "";
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: white;
opacity: 0.05;
transform-origin: center center;
transform: skew(-30deg) scaleY(1) translate(0, 0);
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.strips .strip__inner-text {
will-change: transform, opacity;
position: absolute;
z-index: 5;
top: 50%;
left: 50%;
width: 70%;
transform: translate(-50%, -50%) scale(0.5);
opacity: 0;
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.strips__strip--expanded {
width: 100%;
left: 0 !important;
z-index: 3;
cursor: default;
}
@media screen and (max-width: 760px) {
.strips__strip--expanded {
min-height: 100vh;
}
}
.strips__strip--expanded .strip__content:hover:before {
transform: skew(-30deg) scale(1) translate(0, 0);
opacity: 0.05;
}
.strips__strip--expanded .strip__title {
opacity: 0;
}
.strips__strip--expanded .strip__inner-text {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.strip__title {
display: block;
margin: 0;
position: relative;
z-index: 2;
width: 100%;
font-size: 3.5vw;
color: white;
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
@media screen and (max-width: 760px) {
.strip__title {
font-size: 28px;
}
}
.strip__close {
position: absolute;
right: 3vw;
top: 3vw;
opacity: 0;
z-index: 10;
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
cursor: pointer;
transition-delay: 0.5s;
}
.strip__close--show {
opacity: 1;
}
@keyframes strip1 {
0% {
transform: translate3d(-100%, 0, 0);
}
100% {
transform: translate3d(0, 0, 0);
}
}
@keyframes strip2 {
0% {
transform: translate3d(0, 100%, 0);
}
100% {
transform: translate3d(0, 0, 0);
}
}
@keyframes strip3 {
0% {
transform: translate3d(0, -100%, 0);
}
100% {
transform: translate3d(0, 0, 0);
}
}
@keyframes strip4 {
0% {
transform: translate3d(0, 100%, 0);
}
100% {
transform: translate3d(0, 0, 0);
}
}
@keyframes strip5 {
0% {
transform: translate3d(100%, 0, 0);
}
100% {
transform: translate3d(0, 0, 0);
}
}
/* Demo purposes */
.fas {
position: sticky;
right: 90vw;
top:40vh;
font-size: 70px;
color: white;
}
.fa{
position: sticky;
left: 90vw;
top: 40vh;
font-size: 70px;
color: white;
}
h2{
padding-bottom: 10px;
}
h3{
font-size: 1rem;
font-weight: bold;
}
p {
margin: 0 0 16px;
}
.footer{
display:none;
}
.blackback{
background-color: rgba(0, 0, 0, 0.5);
padding: 30px 0 0 0;
}
.box {
text-align: center;
padding-top: 0px;
padding-left: 50px;
padding-right: 50px;
}
.teams-container{
display:flex;
}
.teams-container div{
padding: 10px;
}
.playerprofile{
width:100%;
text-align:center;
}
.profilepic {
background-image: url(https://i.ibb.co/4jmxcF9/Red.jpg);
background-repeat: no-repeat;
background-position: center;
width: auto;
height: 140px;
margin: 0;
padding: 0;
}
.contain {
object-fit: cover ;
}
img {
width: 200px;
height: 200px;
}
.lookingforteam{
font-weight: bold;
font-size: 1.2rem;
padding-bottom:30px;
}
JavaScript文件:
$(document).ready(function(){
var Expand = (function() {
var tile = $('.strips__strip');
var tileLink = $('.strips__strip > .strip__content');
var tileText = tileLink.find('.strip__inner-text');
var stripClose = $('.strip__close');
var expanded = false;
var open = function() {
var tile = $(this).parent();
if (!expanded) {
tile.addClass('strips__strip--expanded');
// add delay to inner text
tileText.css('transition', 'all .5s .3s cubic-bezier(0.23, 1, 0.32, 1)');
stripClose.addClass('strip__close--show');
stripClose.css('transition', 'all .6s 1s cubic-bezier(0.23, 1, 0.32, 1)');
expanded = true;
}
};
var close = function() {
if (expanded) {
tile.removeClass('strips__strip--expanded');
// remove delay from inner text
tileText.css('transition', 'all 0.15s 0 cubic-bezier(0.23, 1, 0.32, 1)');
stripClose.removeClass('strip__close--show');
stripClose.css('transition', 'all 0.2s 0s cubic-bezier(0.23, 1, 0.32, 1)')
expanded = false;
}
}
var bindActions = function() {
tileLink.on('click', open);
stripClose.on('click', close);
};
var init = function() {
bindActions();
};
return {
init: init
};
}());
Expand.init();
});
答案 0 :(得分:0)
因此解决方案非常简单,我不得不将容器流体的位置更改为相对位置!这样就解决了问题!