So I'm having a problem where some buttons in a seperate div are binding to a header I've absolute positioned the logo's and the intro section is a separate div.
Heres the html including buttons that aren't working
<div class="header">
<div class="logo-right">
<img src="/img/project-logo.png" alt="Hedonist Project" />
<img src="/img/drinks-logo.png" alt="Hedonist Drinks" />
</div>
<div class="logo">
<img src="/img/logo.png" alt="Hedonist Events" />
<h4>a creative drinks consultancy</h4>
</div>
</div>
<div class="intro">
<div class="container">
<div class="intro__text editable"><h3>Hedonist Events are an events agency
for bar staff, bar management, events production and pop-up bars.</h3>
<div class="intro__buttons">
<a class="btn" href="#contact">get in touch</a>
<a class="btn" target="_blank" rel="noopener" href="deck.html">see the event deck</a>
</div>
Heres the css
.logo {
display: flex;
position: absolute;
top: 5.3em;
left: 6.5em;
right: 0;
bottom: 0;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 850px) {
display: block;
left: 4.3em;
}
}
.logo-right {
position: absolute;
top: 5.3em;
right: 12.5em;
bottom: 0;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 1300px) {
right: 8em;
}
#media (max-width: 950px) {
display: none;
}
}
.header {
height: 20em;
width: 100%;
#media (max-width: 1000px) {
height: 10em;
}
}
When using absolute in this case the header as to be relative:. Also using absolute position and you want to align a tag left just use "left" no need for "right" unless you want it to fill the whole space of the relative container. Update your code with the below
.logo {
display: flex;
position: absolute;
top: 5.3em;
left: 6.5em;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 850px) {
display: block;
left: 4.3em;
}
}
.logo-right {
position: absolute;
top: 5.3em;
right: 12.5em;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 1300px) {
right: 8em;
}
#media (max-width: 950px) {
display: none;
}
}
.header {
height: 20em;
width: 100%;
position: relavtive;
#media (max-width: 1000px) {
height: 10em;
}
}
Related
in this code, the font size increases in proportion to the screen ratio
/*
#mixin fontSuperSize($number){
#media (min-aspect-ratio: 2/1) {
font-size: $number * 2vh;
}
#media (max-aspect-ratio: 2/1) {
font-size: $number * 1vw;
}
}*/
#media (min-aspect-ratio: 2 / 1) {
div {
font-size: 8vh; } }
#media (max-aspect-ratio: 2 / 1) {
div {
font-size: 4vw; } }
<div>1234567890987654321</div>
The length of the child elements is more than 100 vmin in total, and therefore the adjustment comes. I need to reduce the scale of the child elements so that the adjustment does not occur on the square screens.
How can I do the same as for text but for a div. That is what I have now...
How can I make it so that the div does not work out
<div class="main">
<div class="auth"></div>
<div class="table" ></div>
<div class="news" ></div>
</div>
<style>
.main {
width: 100vw;
height: 100vh;
}
.auth {
width: 60vmin;
height: 60vmin;
background: blue;
position: absolute;
left: 2%;
right : 2%;
}
.table {
width: 60vmin;
height: 20vmin;
background: green;
position: absolute;
right: 2%;
top: 2%;
}
.news {
width: 70vmin;
height: 20vmin;
background: gold;
position: absolute;
right: 2.5%;
bottom: 2.5%;
}
</style>
I am trying to create a responsive design and using the position absolute to place my image in the right position. Now, is there a way to "lock down" two images to resize together with the size of the screen? I have to keep adjusting the image position using the #media query.
It's driving me insane now. What I want to achieve is both images to move together at the same time.
Have a look at this Fiddle or see the demo below:
body {
margin: 0;
padding: 0;
}
.wrapper {
position: relative;
left: 0;
top: 0;
margin-left: auto;
margin-right: auto;
text-align: center;
overflow: hidden;
max-width: 1200px;
}
.container {
display: inline-block;
max-width: 900px;
}
.absolutecontainerliquids {
height: 450px;
}
.basecloudcontainer {
position: relative;
}
.paddingtop {
padding-top: 30px;
}
.liquids {
position: absolute;
left: 10%;
z-index: 10;
width: 80%;
}
.cloud {
position: absolute;
left: 0%;
width: 100%;
z-index: 1;
}
.darkgrey {
background-color: #262626;
}
.lightgrey {
background-color: #cfcdc7;
}
.page1 {
z-index: 10;
}
.page2 {
padding-top: 40px;
}
.firstimagetabletlogostripes {
display: none;
}
.firstimagelogobottom {
display: none;
}
.firstimagelogo {
width: 64%;
left: 18%;
top: 27%;
position: absolute;
z-index: 1;
}
.blacktext {
color: black;
}
.paragraph {
text-align: center;
padding: 0 30px;
}
#media screen and (min-width: 340px) {
.firstimagelogo {
width: 65%;
top: 25%;
}
}
#media screen and (min-width: 500px) {
.firstimagelogo {
width: 30%;
top: 30%;
left: 35%;
z-index: 10;
}
.firstimagemlogostripes {
visibility: hidden;
}
.firstimagetabletlogostripes {
display: block;
position: absolute;
left: -35%;
top: 0%;
z-index: 2;
width: 120%;
}
}
#media screen and (min-width: 600px) {
.firstimagetabletlogostripes {
top: -10%;
left: -40%
}
}
#media screen and (min-width: 700px) {
.wrapper {
overflow: visible;
}
.absolutecontainerliquids {
height: 650px;
}
.firstimagetabletlogostripes {
top: -20%;
left: -45%;
width: 130%;
}
}
#media screen and (min-width: 800px) {
.firstimagetabletlogostripes {
top: -50%;
left: -50%;
width: 130%;
}
}
#media screen and (min-width: 900px) {
.firstimagetabletlogostripes {
top: -50%;
left: -50%;
width: 130%;
}
}
#media screen and (min-width: 1000px) {
.firstimagetabletlogostripes {
top: -60%;
left: -30%;
width: 120%;
}
.firstimagelogo {
width: 20%;
top: 25%;
left: 40%;
z-index: 10;
}
.firstimagelogotop {
display: block;
position: absolute;
top: -0%;
left: 70%;
width: 40%;
}
.firstimagelogobottom {
display: block;
position: absolute;
top: 70%;
left: 15%;
width: 40%;
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Base - E-Liquid</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="wrapper darkgrey page1">
<div class="container">
<img class="firstimagemlogostripes" src="https://image.ibb.co/g5WJ66/mlogostripes.png" />
<img class="firstimagetabletlogostripes" src="https://preview.ibb.co/gFnrR6/stripes.png" />
<img class="firstimagelogo" src="https://image.ibb.co/gsPGtm/logofilled.png" />
<img class="firstimagelogobottom" src="https://preview.ibb.co/gkXEeR/imagelogobottom.png" />
</div>
</div>
<div class="wrapper lightgrey page2">
<div class="container absolutecontainerliquids">
<div class="paragraph blacktext">
<p>Ecstatic advanced and procured civility not absolute put continue. Overcame breeding or my concerns removing desirous so absolute. My melancholy unpleasing imprudence considered in advantages so impression. Almost unable put piqued talked likely
houses her met. Met any nor may through resolve entered. An mr cause tried oh do shade happy.
</p>
</div>
</div>
</body>
</html>
This is the HTML:
<div class="bck">
<div class="image-1"></div>
</div>
And CSS:
.bck {
background-image="image url"
}
.image-1 {
margin-top: 40px
margin-left: 40px
}
You can use div tag and put your both image in it. If you are using external css then create a class and apply that class to both of images.
Update:
This is Html file:
<div class="bck">
<div class="image-1"></div>
</div>
And css:
.bck{
background-image="image url"}
.image-1{
margin-top: 40px
margin-left: 40px}
I have two lists that's location I would like to move as the screen size gets smaller. When the screen reaches 327px in length, I would like the "headlogo" to be centered on the screen, and everything else exactly as it is... how do I do this?
#charset "utf-8";
/* CSS Document */
body {
margin: 0;
padding: 0;
background-color: #DDDCDC;
}
ul {
list-style-type: none;
}
li {
display: inline;
padding: 10px;
}
.secondlist {
margin-top: 30px;
}
#headlogo {
width: 80px;
margin-left: 10px;
margin-top: 10px;
}
.firstlist {
position: relative;
float: left;
}
.secondlist {
position: absolute;
right: 0;
margin-right: 50px;
margin-top: 50px;
z-index: 2;
}
li#about {
width: 5px;
}
#media only screen and (max-width: 610px) {
.firstlist {
position: relative;
float: left;
}
.secondlist {
position: relative;
right: 0;
margin-right: 50px;
margin-top: 50px;
z-index: 2;
text-align: center;
}
li {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
li.listli {
line-height: 30px;
}
#headlogo {
width: 80px;
margin-left: 10px;
margin-top: -22px;
}
}
#media only screen and (max-width: 424px) {
#headlogo {
margin-top: -3px;
}
}
#media only screen and (max-width: 394px) {
#headlogo {
margin-top: 7.5px;
}
}
#media only screen and (max-width: 327px) {
#centerme {
display: inline-block;
position: relative;
top: 30px;
}
.firstlist {
float: none;
display: block;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
li.listli {
position: relative;
top: -10px;
}
}
<div id="centerme">
<ul class="firstlist">
<a class="alist" href="http://www.coopertimewell.com">
<li class="listl" id="image">
<img id="headlogo" src="images/logotestme.png" />
</li>
</a>
</ul>
</div>
<ul class="secondlist">
<a class="alist" href="#">
<li class="listli" id="home"><strong>HOME</li></a>
<a class = "alist" href = "http://www.coopertimewell.com/about"><li class = "listli" id = "about">ABOUT ME</li></a>
<a class = "alist" href = "http://www.coopertimewell.com/work"><li class = "listli" id = "work">PORTFOLIO</li></a>
<a class = "alist" href = "http://www.coopertimewell.com/contact"><li class = "listli" id = "contact">CONTACT</li></a>
</ul>
If you would only center it horizontally u have to edit #center in the 'max-width: 327px' query to the following:
#centerme {
display: block;
position: relative;
top: 30px;
width: 100%;
text-align: center;
}
I made the #center div a 100% width and set the text-align to center, which affects the image also. So this way you can center the image horizontally.
Or if you would center it horizontally and vertically you can use:
#centerme {
display: block;
position: relative;
top: 50%;
transform: translateY(50%);
-webkit-transform: translateY(50%);
width: 100%;
text-align: center;
}
With the same code from above I added
top: 50%;
transform: translateY(50%);
to center it horizontally.
Goodluck!
This should centre it below 327px;
#media (max-width: 327px){
#headlogo{
display: block;
margin: 0 auto
}
}
Check this out for more info
You can do
#media (max-width: 327){
#headlogo{
//with your code her//
}
}
Or you can use a new css file with media added
<link rel="stylesheet" media="screen and (max-width: 327px)" href="small.css/>
With this line you can add a complete new css if your screen will be 327px or smaller.
I've been playing with this grid for a while, it's a two grid system in which i'm trying to add two different images. I've added the images with success. However, It's when i try to make two separate containers for the text i would like to place over the images everything goes wrong. Been trying to wrap my head around this for hours without results.
I did succeed to add text over the image with the one column. However, these two columns just won't let me.
What is the best way to solve this?
CSS
/* SECTIONS */
.section-ad {
clear: both;
padding: 0px;
margin:0;
}
/* COLUMN */
.col {
display: block;
float:left;
margin: 0% 0% 0% 1%;
}
.col:first-child { margin-left: 0; }
/* GROUP */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* TWO GRID */
.span_2_of_2 {
width: 100%;
height: auto;
}
.span_1_of_2 {
width: 49.5%;
height: auto;
}
.span_2_of_2 img {
width: 100%;
height: auto;
}
.span_1_of_2 img {
width: 100%;
height: auto;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 480px) {
.col {
margin: 0% 0 0% 0%;
}
}
#media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
HTML
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?11274335160121521292" />
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
</div>
</div>
Best Regards,
Robin.
You can place text over image following way.
Add span inside col div and add text inside. And give position:absolute and parent div to position:relative;. Then you can set it's position using left and right value.
.section-ad {
clear: both;
padding: 0px;
margin:0;
}
/* COLUMN */
.col {
display: block;
float:left;
margin: 0% 0% 0% 1%;
position: relative;
}
.col:first-child { margin-left: 0; }
/* GROUP */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* TWO GRID */
.span_2_of_2 {
width: 100%;
height: auto;
}
.span_1_of_2 {
width: 49.5%;
height: auto;
}
.span_2_of_2 img {
width: 100%;
height: auto;
}
.span_1_of_2 img {
width: 100%;
height: auto;
}
span {
color: #000000;
font-size: 25px;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 480px) {
.col {
margin: 0% 0 0% 0%;
}
}
#media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?11274335160121521292" />
<span>Some text</span>
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
<span>Some text</span>
</div>
</div>
Thanks to all your replies.
Ketan - Altough your solution worked, it did not fit my needs.
However, thanks to your reply i managed to surpass my blackout. So i owe it too you anyway. Thanks!
This might now be the best way,
but this is how i did it.
CSS
CSS
/* TVĂ… KOLUMN ADVERT # 705x450 */
.span_1_container {
position: absolute;
top: 80%;
left: 25%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
width: 45%;
}
.span_1_heading {
font-size: 20px;
line-height: 100px;
display:inline-block;
position: relative;
}
.span_2_container h2:before {
content: '';
border-top: 1px solid #383a4f;
position: absolute;
width: 25%;
left: 35%;
top: 50px;
}
.span_2_container {
position: absolute;
top: 25%;
left: 0%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
width: 45%;
}
.span_2_container h2:after {
content: '';
border-bottom: 1px solid #383a4f;
position: absolute;
width: 25%;
left: 35%;
bottom: 50px;
padding-bottom: 20px;
}
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?5000542013708637763" />
<div class="span_1_container">
SHOP NOW</div>
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
<div class="span_2_container">
<h2 class="span_2_heading" style="font-weight: normal; color: #383a4f;">Pocketsquares</h2>
<p style="font-family: 'Lato'; font-size: 14px; color: #383a4f; line-height: 15px; padding-bottom: 20px;">Explore our premium pocketsquares.</p>
SHOP NOW</div>
</div>
</div>
I am trying to change the positions of the buttons which will scale down to mobile relative to the image div. I tried position/absolute; but it didn't take effect. Neither did the buttons stay relative inside the image div. I am not sure if the media queries will do the job or not. Any solutions?
<div id="hero-wrapper" class="main_wrapper hero">
<img src="images/home-hero-image.jpg" alt="fruute">
<div class="herobuttons"><div id="hero-shop-cookies" class="hero-btn">shop cookies</div>
<div id="hero-shop-gifts" class="hero-btn">shop gifts</div></div>
</div>
CSS
#hero-shop-cookies {
top: 398px;
left: 550px;
}
#hero-shop-gifts {
top: 398px;
left: 715px;
}
.main_wrapper hero{
width: 100%;
}
#hero-wrapper{
position: relative;
}
.hero-wrapper > .hero-btn a{
position: absolute;
left: 0;
right: 15px;
bottom: 20px;
top: 0;
background-color: red;
}
#media screen and (min-width: 768px) {
#nav-menu{
display: none;
}
#navigation li, #navigation a{
float:left;
}
.main_wrapper hero, .hero-btn{
width: 100%;
}
.herobuttons{
position: relative;
left: 0;
top: 0;
}
#slideshow-area{
width: 300px;
}
}
Change min-width: 768px; to max-width: 768px;