使用固定背景附件和旋转容器重复背景?

时间:2017-12-04 10:58:02

标签: html css css3 sass background-attachment

是否可以在以下条件下重复无缝模式?

想法是让一个带有固定附件的旋转背景。我认为这应该是如何运作的,但有没有办法实现这一目标?

body {
  padding: 50px;
  margin: 0;
  height: 10000px;
}

.main {
  width: 100%;
  height: 1300px;
  box-sizing: border-box;
  overflow: hidden;
  border: 5px solid #7cb7b7;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.background {
  background-image: url('https://thumbs.dreamstime.com/b/circles-seamless-pattern-10032830.jpg');
  background-attachment: fixed;
  background-repeat: repeat;
  position: absolute;
  top: -1000%;
  left: -1000%;
  right: -1000%;
  bottom: -1000%;
  transform: rotate(-15deg);
}

.text {
  background: white;
  border: 2px solid black;
  width: 200px;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}
<div class="main">
  <div class="background"></div>
  <div class="text">
   <p>Flex</p>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        body {
  padding: 50px;
  margin: 0;
  height: 1000px;
}

.main {
  width: 100%;
  height: 1000px;
  box-sizing: border-box;
  overflow: hidden;
  border: 5px solid #7cb7b7;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.image {
  background-image: url('images/attractions01.jpg');
  background-attachment: fixed;
  background-repeat: repeat;
  position: absolute;
  top: -1000%;
  left: -1000%;
  right: -1000%;
  bottom: -1000%;

}

.text {
  background: white;
  border: 2px solid black;
  width: 200px;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}
    </style>
</head>
<body>
<div class="main">
  <div class="image"></div>
  <div class="text">
   <p>Flex</p>
  </div>
</div>
</body>
</html>
相关问题