【发布时间】:2018-04-25 20:40:46
【问题描述】:
想知道您是否可以提供帮助。在谷歌上用这个在房子周围转转。
基本上,我正在尝试在 SASS 中构建网站,而不是有意使用任何 css 框架。但是我在制作我的两篇文章时遇到了问题,出现在我的标题/标题图像下......这是该网站目前的外观:
问题是,我在标题上有一些 javascript,如果您在图像上移动鼠标,图像会在鼠标移动的任何方向上平移。这似乎只有在标题设置为:position: absolute;
时才有效因此,我的文章位于标题的顶部/内部。
如果我删除 position: absolute,那么只有这样,我的文章才会位于标题下方。但是随后 javascript 不起作用...
以下是我目前使用的 CSS/SASS:
header {
// background-image: url(https://kordastudio.hu/wp-
content/uploads/2017/01/blade-runner-2049_.jpg);
background-image: url(/assets/images/futuristic_background.jpg);
background-position: center;
background-size: 100%;
position: absolute;
background-repeat: no-repeat;
top: 0;
left: 0;
z-index: -1;
/* Preserve aspet ratio */
min-width: 110%;
min-height: 500px;
}
.container {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
// position:relative;
// padding:10px;
margin: 0 auto;
width: 100%;
min-height: 100vh; /* make sure wrapper is taller enough */
border: solid thin #060;
// overflow: hidden; /* Add this */
}
.flex-item:nth-child(1) {
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.flex-item:nth-child(2) {
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.flex-item:nth-child(3) {
order: 0;
flex: 0 1 auto;
align-self: auto;
}
HTML:
<body>
<main>
<nav>
<ul>
<li>about me</li>
<li>projects</li>
<li>timeline</li>
<li>linkedin</li>
<li>github</li>
</ul>
</nav>
<!-- Background image and title -->
<div class="container">
<header id="header" class="gradient flex-item">
<h1>hello</h1>
</header>
<!-- grey container -->
<article class="flex-item">
text
</article>
<article class="flex-item">
text
</article>
</div>
<main>
真的很烦!与这个斗争!提前致谢!
【问题讨论】:
标签: css sass css-position positioning