2

Is it possible to get seamless pattern repeat with following conditions?

Idea is to have one rotated background with fixed attachment. I think this is how is supposed to be working, but are there any ways of achieving that?

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>
Sunil Hari
  • 1,716
  • 1
  • 12
  • 20
  • Looks pretty seamless to me, so I'm not sure what the question is. – Mr Lister Dec 04 '17 at 11:13
  • @MrLister try it in Chrome. It renders different in FF. He wants the background to cover the entire box. The fact that this is working on the first place is a miracle. Seems pretty hacky to me and only works in Chrome. – Miro Dec 04 '17 at 11:15
  • That's right. Forgot to mention it's in Chrome. @Miro, I know it's hacky. Just trying to get some other ideas. – Bogdan Dogaru Dec 04 '17 at 11:34
  • Would **background-attachment: local;** do what you expect? – bummi Dec 04 '17 at 12:38
  • @bummi, no, that just returns background-image to initial state. – Bogdan Dogaru Dec 04 '17 at 16:17
  • If you can live with a scaling of the image position: absolute; width: 200%; height: 200%; top: -50%; left: -50%; transform: rotate(-15deg); should do the job. – bummi Dec 04 '17 at 16:47

1 Answers1

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>
Shweta
  • 1
  • Is this supposed to be the answer? It doesn't work. The CSS now uses different classes and a non-existent image, so there's nothing visible. – Mr Lister Dec 04 '17 at 13:18