i have location pins on top of background image.
but when its responsive pins location chages.
i want set pins at specific position of images
<div class="container">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin1">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin2">
</div>
css
body {
background: url(http://connect.homes.com/wp-content/uploads/2012/05/200392710-0012.jpg) no-repeat center center fixed;
/* -webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;*/
color: white;
font-family: 'Open Sans', 'Nunito', sans-serif;
}
.pin1 {
position: absolute;
width: 30px;
height: auto;
top: 10%;
left: 28%;
}
.pin2 {
position: absolute;
width: 30px;
height: auto;
top: 40%;
left: 50%;
}
i am trying to set position but its not working
Don't use a background image as it's not responsive in the same way as positioning. Use an actual inline image in a wrapper and position your pins on that.
Here's an example:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-align: center;
}
.map {
margin: 10px;
border: 5px solid red;
position: relative;
display: inline-block;
}
.map img {
max-width: 100%;
display: block;
}
.box {
width: 8%;
height: 8%;
background-image: url(http://www.clker.com/cliparts/W/0/g/a/W/E/map-pin-red.svg);
background-position: top center;
background-repeat: no-repeat;
background-size: contain;
position: absolute;
}
#pin-1 {
top: 29%;
left: 36%;
}
.box:hover>.pin-text {
display: block;
}
.pin-text {
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 75%;
white-space: nowrap;
display: none;
}
.pin-text h3 {
color: white;
text-shadow: 1px 1px 1px #000;
}
<div class="map">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg/800px-Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg" alt="" />
<div id="pin-1" class="box">
<div class="pin-text">
<h3>My House</h3>
</div>
</div>
</div>
Related
I have a slightly rotated div creating an asymetrical graphic on my start page. I use overflow: hidden to hide the overlap from that div. Everything uses absolute positioning to get the elements exactly where I want them and vw and vh to make it responsive. It looks great while the aspect ratio is "normal" but when the window approaches a 2 or 3:1 aspect ratio (like an ultrawide monitor) everything overlaps. Narrow aspect ratio is not a problem since I have it switch to mobile view before it becomes a problem.
I considered using overflow: auto so it wouldn't be forced to fit in the viewport but then it's possible to see the edges of the rotated div.
Is there a solution to this or is this perhaps bad practice and should be done differently?
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#body {
overflow: hidden;
background: red;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.shape {
position: absolute;
right: -10%;
top: -50%;
height: 200%;
width: 45%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
<body id="body">
<div class="shape"></div>
<div class="wrapper">
<div id="welcome" autofocus>
<h1>Welcome</h1>
<p>More Text Here</p>
</div>
</div>
<div class="wrapper">
<input type="button" id="startbtn" onclick="getstarted()" value="Get Started">
</div>
</body>
</html>
Thanks!
Welcome to Stackoverflow.
Putting the shape into the same container (I used the first wrapper) as your content should fix the problem. Why is this: Because the white shape should be in relation to your content. Also I did put the button in the same container.
And you dont need background-sizes for your body as it is just plain red.
I might have messed up your original dimensions, but this should do the trick.
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
body {
overflow: hidden;
background: red;
}
.wrapper {
position: relative;
height: 100%;
}
.shape {
position: absolute;
margin-top: -50%;
margin-right: -50%;
right: 0;
height: 300%;
width: 100%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#body {
overflow: hidden;
background: red;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.wrapper {
position: relative;
height: 100%;
}
.shape {
position: absolute;
margin-top: -50%;
margin-right: -50%;
right: 0;
height: 300%;
width: 100%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
<div class="wrapper">
<div class="shape"></div>
<div id="welcome" autofocus>
<h1>Welcome</h1>
<p>More Text Here</p>
</div>
<input type="button" id="startbtn" onclick="getstarted()" value="Get Started">
</div>
I want the about div to show up BELOW the
full screen home card
I'm having troubles getting it to show like it should.
my html code has both divs in the "right" order and when i look it up online, i couldn't find any solutions.
<body>
<div class="homeCard">
<div class="homeCardTitle">
<h1>Robin Riezebos</h1>
</div>
</div>
<div class="aboutCard">
<div class="aboutCardText">
<h2>About</h2>
</div>
</div>
</body>
my css is either missing something or I did something completely wrong but I can't seem to find out what it is so please help...
index.css
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
height: 100%;
width: 100%;
position: fixed;
float: left;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
position: fixed;
width: 100%;
height: 320px;
top: 50%;
margin-top: -160px;
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
background-color: #1F1F1F;
color: white;
height: 500px;
}
Please change your css like below, i think the problem was with position fixed, if you want to get your background image rendered fully please respective pixels of height.
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
width: 100%;
position: relative;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
background-color: #1F1F1F;
color: white;
height: 500px;
}
I have found a solution by bugging around in my css.
Turns out in stead of position: fixed; I should have used background-attachment: fixed; and remove position all-together.
this is my own fixed code:
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
height: 100%;
width: 100%;
background-attachment: fixed;
float: left;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
position: relative;
width: 100%;
height: 0px;
top: 50%;
margin-top: -90px;
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
width: 100%;
background-color: #1F1F1F;
color: white;
height: 320px;
float: left;
text-align: center;
}
Can Anyone help me to solve a problem that I found on the last version of Chrome?
I found a problem on Chrome new version regarding the DIV Background in 3D.
In the Chrome versione 61.0.3163.100 the same page was rendered well.
On Safari, Internet Explore, Edge and Firefox the page is rendered without any problem.
I attached in this message just a little part of the original HTML page in order to show which is the problem.
Thanks in advance
Andrea Angeli
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333;
background-color: #fff;
}
.container-fluid {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.corr-container {
text-align: center;
position: relative;
}
.cube {
-moz-perspective: 600px;
perspective: 600px;
-webkit-perspective: 600px;
position: relative;
width: 100%;
display: inline-block;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
}
.cube {
height: 550px;
perspective-origin: 50% 275px;
-webkit-perspective-origin: 50% 275px;
}
.cube-face-top {
left: 0;
width: 100%;
height: 3300px;
transform: rotateX(-90deg);
-webkit-transform: rotateX(-90deg);
transform-origin: center top;
-webkit-transform-origin: center top;
background-image: url(https://www.trulytaly.com/ElementiGrafica/Corridoi/Nuovi/Soffitto.png);
background-size: 100% 550px;
-webkit-background-size: 100% 550px;
}
.cube-face {
position: absolute;
top: 0;
}
.plaza-face-top {
background-repeat: no-repeat;
background-image: url(https://www.trulytaly.com/ElementiGrafica/Piazze/NuoviFilePiazza/CUT-FOTOGALLERIA2-B2-TOP.jpg);
width: 100%;
height: 550px;
background-size: 100% 550px;
position: absolute;
top: 100%;
}
.plaza-face,
.r-plaza-face {
position: absolute;
top: 0;
}
.plaza-face,
.r-plaza-face {
position: absolute;
top: 0;
}
.rplaza-face-top {
background-repeat: no-repeat;
background-image: url(../ElementiGrafica/Piazze/NuoviFilePiazza/CUT-FOTOGALLERIA2-B2-TOP.jpg);
width: 100%;
height: 550px;
background-size: 100% 550px;
position: absolute;
top: -550px;
}
.dropdown-flag {
position: relative;
display: inline-block;
}
.dropdown-content-flag {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 12px 16px;
}
.dropdown-flag:hover .dropdown-content-flag {
display: block;
}
.col-sx-dx-div-principale {
display: none;
width: 0;
height: 0;
}
#media screen and (min-width: 1900px) {
.div-principale {
max-width: 90%;
position: relative;
float: left;
}
.col-sx-dx-div-principale {
display: block;
position: relative;
float: left;
background-color: white;
transform-style: preserve-3d;
transform: translateZ(20000px);
z-index: 9999999;
height: 900px;
width: 5%;
}
}
}
<div class="div-principale" style="margin: 0 auto; padding: 0;">
<div class="container-fluid" style="padding: 0px;">
<div style="padding-right:0px;padding-left:0px;" class="virtual-container">
<div class="corr-container">
<div class="cube-container">
<div id="cube" data-inverted="false" class="cube" data-p="front">
<div class="cube-face ct cube-face-top">
<div class="pt plaza-face plaza-face-top"></div>
<div class="pt plaza-face rplaza-face-top" style="display:none"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
we have the following div structure, where we would like to horizontally center both the image and the text within the container div. However, the image is left aligned and only the title is centered.You could find the code below:
.QHeader {
position: absolute;
margin-top: 96px;
margin-left: 0px;
width: 800px;
height: 415px;
background-image: url('../img/bg_blue_rect.png');
background-repeat: no-repeat;
background-position: left top;
}
#QHeaderImg01 {
position: absolute;
display: block;
margin: 0 auto;
margin-top: 72px;
width: 263px;
height: 221px;
background-color: #0F0;
}
.QHeaderTitle {
position: absolute;
margin-top: 324px;
margin-left: 0;
width: 800px;
height: auto;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
font-weight: bold;
color: #000;
}
<div class="QHeader">
<img id="QHeaderImg01" src="img/q_header_img_01.png" />
<div class="QHeaderTitle">
TITLE
</div>
<!--QHeaderTitle-->
</div>
<!--QHeader-->
Just remove your position: absolute; or change it to position: relative;, as you will not need absolute positioning to horizontally center your elements:
.QHeader {
width: 800px;
height: 415px;
background-image: url(http://placehold.it/800x415);
background-repeat: no-repeat;
background-position: left top;
}
#QHeaderImg01 {
display: block;
margin: 0 auto;
width: 263px;
height: 221px;
background-color: #0F0;
}
.QHeaderTitle {
margin-top: 50px;
width: 800px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
font-weight: bold;
color: #000;
}
<div class="QHeader">
<img id="QHeaderImg01" src="http://placehold.it/263x221/0c0" />
<div class="QHeaderTitle">
TITLE
</div>
<!--QHeaderTitle-->
</div>
<!--QHeader-->
just change
#QHeaderImg01 {
position:absolute;
}
to
#QHeaderImg01 {
position:relative;
}
and of cource, remove the big margin-top
div.container {
height: 10em;
position: relative }
div.container p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto;
}
<body>
<div class=container>
<IMG class="displayed" src="http://labs.qnimate.com/slider/1.jpg" alt="...">
<p>Centered!
</div>
or
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto;
}
div.container {
height: 10em;
position: relative }
div.container p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
<IMG class="displayed" src="http://labs.qnimate.com/slider/1.jpg" alt="...">
<div class=container>
<p>Centered!
</div>
I'm trying to center content over a fullscreen slick slider (kenwheeler.github.io/slick/),
I've attempted to use a flex box but the content remains at the edge of the viewport, which appears to be an issue with the position tag of the slick css but I can't figure out what I'm doing wrong.
It's my first time working with flex so maybe I'm missing something?
Website live here
HTML
<div class="wrapper">
<div class="main">
<img class="logo" src="img/logo.png">
<h1>XXXXXX</h1>
<h2>XXXX is a collaboration between XXXX & XXXX</h2>
</div>
<div class="background">
<div class="slide" style="background: url('bg/hlg1.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg2.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg3.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg4.jpg') no-repeat center center"></div>
</div>
CSS
*{
min-height: 0;
min-width: 0;
cursor: crosshair;
}
html{
height: 100%;
min-height: 100%;
}
body{
font-family: sans-serif, "Helvetica", "Arial";
font-weight: bold;
font-size: 62.5%;
color: #fff;
text-align: center;
height: 100%;
margin: 0;
padding: 0;
width: 100%;
background: #000;
min-height: 100%;
overflow: hidden;
}
.wrapper {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.slide {
height: 100%;
width: 100%;
background-size: cover !important;
}
.background {
height: 100%;
width: 100%;
z-index: 0;
}
.slick-list,
.slick-track {
height: 100%;
}
.slick-prev {
position: fixed;
left: 2vw;
height: 4vh;
width: 3vw;
z-index: 2;
}
.slick-next {
position: fixed;
right: 2vw;
height: 4vh;
width: 3vw;
z-index: 2;
}
.slick-slider {
margin-bottom: 0;
}
.arrow:hover {
cursor: crosshair;
}
.main {
flex: none;
top: 3vh;
z-index: 1;
max-width: 50%;
position: absolute;
}
.logo {
width: 25vw;
margin: auto;
}
Since that element (main) stays there all the time, you can use these settings:
.main {
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
z-index: 1;
}