I need a div filled with colour that goes across the screen behind the bottles like this:
Have tried too many times now...
Here is my html:
.panel {
height: 100vh;
width: 100vw;
display: block;
}
.OriginalCollection {
background: url(img/page_5_background.png);
}
.inner2 {
height: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
overflow: hidden;
}
.centerwraper {
position: relative;
height: auto;
margin: 0 auto;
padding: 10px;
}
.centerdivcollections {
margin: 0 auto;
text-align: center;
max-width: 1080px;
}
.allbottleswrap {
display: flex;
}
.singlebottle {
width: 100%;
}
#media (max-width: 1200px) {
.singlebottle {
width: 100%;
}
}
.bottletextwraper {
display: inline-block;
vertical-align: middle;
}
.bottletext {
padding: 0px 5px 0px 0px;
}
.titlebottle {
width: 90%;
.stripeee {
background-color: #662d91;
width: 100vw;
height: 30px;
position: absolute;
left: 0;
right: 0;
margin-top: -45px;
}
<section class="panel OriginalCollection" data-section-name="OriginalCollection">
<div class="inner2">
<div class="centerwraper">
<div class="centerdivcollections">
<div>
<img class="coltitle" src="img/original_header.png" />
</div>
<div class="allbottleswrap">
<div class="bottletextwraper">
<div>
<img class="singlebottle" src="img/1Heisenberg.png" />
</div>
<div>
<img class="titlebottle" src="Titles/Titles/Heisenberg.png" />
</div>
<div class="bottletext">
<p>A top secret recipe that can only be described as the daddy of all day vapes. A fruity undertone and a cool crystal after sensation that will leave you wondering what it is... and wanting more.</p>
</div>
</div>
<div class="bottletextwraper">
<div>
<img class="singlebottle" src="img/2Pinkman.png" />
</div>
<div>
<img class="titlebottle" src="Titles/Titles/Pinkman.png" />
</div>
<div class="bottletext">
<p>The real MVP of the fruity flavours. Perfect for those looking for a one of a kind taste sensation. A true mouth-watering fruit explosion that your taste buds have been waiting for.</p>
</div>
</div>
<div class="bottletextwraper">
<div>
<img class="singlebottle" src="img/3BloodSukka.png" />
</div>
<div>
<img class="titlebottle" src="Titles/Titles/BloodSukka.png" />
</div>
<div class="bottletext">
<p>Packed with one hell of a bite. This flavour is crammed with sweet red cherries blended perfectly with fresh picked forest fruits. The fruity taste is then entangled beautifully with sweet eucalyptus and aniseed.</p>
</div>
</div>
</div>
<div class="stripeee">
<br>
</div>
</div>
</div>
</div>
</section>
Everything is almost done as I want, except this stripe... If you want you can always go to www.konceptxix.com to see the actual site. It's probably an easy fix for someone who knows it well. Sorry for mess in the code, I'm doing my best...
UPDATE:
I can get this set to a position behind it, but it has to be responsive so it's the same on mobile etc...
I'm assuming you want this to go all the way across the page? You'll want to use a pseudo element instead of a div, since it's just a decoration, and you can set the width to something impossibly wide to guarantee it fills the page - you already have overflow set to hidden on the sections, so it won't matter if it gets too wide. I used 150vw and set the left to -50vw, to guarantee that it's always at the far-left of the screen and goes all the way across.
From there, I needed to find a way to target the container for the images, that way I could position the pseudo element consistently as the image gets scaled down without worrying about overlapping the text. So I target the first bottle's first div, which is always the image, that way using different sized images doesn't cause weird double dividers. The result should be what you're looking for!
.bottletextwraper div:first-of-type{
position: relative;
}
.bottletextwraper img{
position: relative;
z-index: 1;
}
.bottletextwraper:first-child div:first-of-type:after{
content: '';
display: block;
width: 150vw;
position: absolute;
bottom: 3%;
left: -50vw;
height: 15%;
background: #662d91;
}
.bottletextwraper {
display: inline-block;
vertical-align: middle;
position: relative;
}
.bottletextwraper::after{
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 100px;
background-color: orange;
}
Try to add this.
Because the stripee is outside of allbottletexwrapper its harder to correctly set the z-indexing. If you can move it inside, you can do without z-index hacks. But anyway, here is what you can do:
//set stripee to be relative and positioned (use your size units)
.stripeee {
position: relative;
top: -190px;
z-index: 1;/*mind this... a bit hacky but... */
}
And then style the bottles:
.bottletextwraper {
z-index: 5; /* use whatever number you consider safe according to the rest of page*/
}
Related
ok so i've been working on this website. mostly just as kind of a proof of concept. i haven't coded a website in quite some time now so this is basically me trying to get back onto the horse as they say.
anyway, i've searched this forum for some time now and i did find quite a few questions very similar to mine. but somehow all the solutions and all the ideas they gave me did not seem to work for me. now maybe i have a typo somewhere making my browser go crazy and misinterpret the code i don't know. what i want to do is create something like a fluid layout with 4 "columns" all being 1/4 of the canvas and full height. in each of these four columns i want to place an image which i want to be center center. so that i can move the image up to the top of the column and have some text at the center on mouseover. thing is i can't seem to find a way to place the image in the center. i tried using and containers. i even tried just aligning the without a container, but it just won't go where i want it. as i mentioned maybe i have a typo somewhere or something.
any
so this is the html code i use for layout
<body>
<div id="col_home">first text first text</div>
<div id="col_so"> text text text</div>
<div id="col_tra">
<div id="picture">
<img src="img/Ordner ZU.png" width="100px" height="100px" />
</div>
image title
</div>
<div id="col_co">last text last text</div>
</body>
and this is the css i use for formatting
html {
width: 1024px;
height: 768px;
margin: auto;
border: 1px solid;
}
body, div {
margin: 0px;
width: 100%;
height: 100%;
}
#col_home {
position: relative;
float: left;
left: 0%;
top: 0%;
width: 25%;
height: 100%;
}
#col_so {
position: relative;
float: left;
left: 0%;
top: 0%;
width: 25%;
height: 100%;
background-color: rgb(255, 255, 1);
}
#col_tra {
position: relative;
float: left;
left: 0%;
top: 0%;
width: 25%;
height: 100%;
background-color: rgb(255, 204,51);
}
#col_co {
position: relative;
float: left;
left: 0%;
top: 0%;
width: 25%;
height: 100%;
background-color: rgb(255, 153, 0);
}
#picture {
position: absolute;
left: 50%;
clear: left;
}
thanks to any- and everyone for help. as i said i'm mostly doing this for fun but still i would like to figure out a possible solution for my learning curve ;). i did run it with id-tags first but for now i don't think it makes a difference at least not in the results i get.
An easy way to achieve this is using flexbox. To center a child element in its parent, you can use justify-content:center; which aligns an item horizontally, and align-items:center - vertically. flex-flow:row makes your child elements display in a row, if you want them to display in a column, use flex-flow:column. You can see the result by running the snippet by clicking the button below.
html {
width: 1024px;
height: 768px;
margin:auto;
border: 1px solid;
}
body, div {
margin:0;
width: 100%;
height: 100%;
display:flex;
flex-flow:row;
}
#col_home {
width:25%;
}
#col_so {
width:25%;
background-color: rgb(255, 255, 1);
}
#col_tra {
width:25%;
flex-flow:column;
background-color: rgb(255, 204,51);
}
#col_co {
width:25%;
background-color: rgb(255, 153, 0);
}
#picture{
justify-content:center;
align-items:center;
}
<body>
<div id="col_home">first text first text</div>
<div id="col_so"> text text text</div>
<div id="col_tra">
<div id="picture">
<img src="img/Ordner ZU.png" width="100px" height="100px"/>
</div>
</div>
<div id="col_co">last text last text</div>
</body>
Using float for column layouts like this is a thing of the past - you really want to use the flexible box model (aka "flexbox"). In the example below you can see that setting up the columns takes considerably less CSS code and each column always tries to take up any available space by "flexing." Since there are 4 columns, they all always take up 25% of the space.
Then within any individual column, you can use traditional relative positioning with top/left and margin offsets to perfectly center the image:
html, body {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-flow: row;
}
.col {
flex: 1 1 auto;
position: relative;
}
#col2 {
background-color: rgb(255, 255, 1);
}
#col3 {
background-color: rgb(255, 204,51);
}
#col4 {
background-color: rgb(255, 153, 0);
}
#picture {
left: 50%;
margin-left: -50px;
margin-top: -50px;
position: relative;
top: 50%;
}
<div class="col" id="col1"></div>
<div class="col" id="col2"></div>
<div class="col" id="col3">
<div id="picture">
<img src="img/Ordner ZU.png" width="100px" height="100px" />
<br>image title
</div>
</div>
<div class="col" id="col4"></div>
Not sure exactly what you're trying to do on mouse hover, but this should get you pretty close. You could also turn each column into a flexing box and try to align the image with justify or align properties but that might get tricky with hover effects.
I have a parent div that contains two children, side by side. The first child is an image that must be height 100% and 58% width, margin auto and overflow hidden. The second child contains text, and the length of the text determines the height of the parent. This is a template for several pages, with different length of text, and therefore different parent height. Is it possible to do what I'm trying to do without using JS? Thanks for your input! Code below.
HTML:
<div id="product-summary">
<div class="product-image-container">
<img />
</div>
<div id="product-details">
<h3 class="product-title"></h3>
<div class="product-description"></div>
</div>
</div>
CSS:
.product-image-container {
position: absolute;
top: 0;
left: 0;
width: 58%;
height: 100%;
overflow: hidden;
img {
position: absolute;
top: 0;
left: 50%;
margin: auto;
transform: translateX(-50%);
min-width: 100%;
height: 100%;
}
}
#product-details {
float: right;
border: solid thin #777;
height: ~"calc(100% - 2px)";
width: 41%;
text-align: center;
}
The problem is your #product-details is floated, which creates a new BFM (block formatting context), and the parent gets collapsed.
I suggest you read more about BFMs here: http://yuiblog.com/blog/2010/05/19/css-101-block-formatting-contexts/
There are several ways to fix this:
You could clear the parent, a way to do that is by adding overflow: hidden; to the #product-summary element.
You could remove the float: right from #product-details, and use flexbox to align it instead.
I don't know any preprocessor wizardry, but using inline-block works good, as well as keeping positioned absolute elements wrapped in a relative parent for control. It wasn't mentioned how the image is displayed, so I assume aspect ratio unchanged and no cropping.
SNIPPET
.product-image-container {
display: inline-block;
position: relative;
top: 0;
left: 0;
right: 0;
width: 58%;
height: 100vh;
overflow: hidden;
}
img {
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: auto;
}
#product-details {
float: right;
border: 1px solid #777;
height: 100%;
width: 41%;
text-align: center;
}
a {
margin-left: 50%;
}
<div id="product-summary">
<div class="product-image-container">
<img src='https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png'>
</div>
<div id="product-details">
<h3 class="product-title">Lena Söderberg</h3>
<div class="product-description">
<blockquote>Lenna or Lena is the name given to a standard test image widely used in the field of image processing since 1973. It is a picture of Lena Söderberg, shot by photographer Dwight Hooker, cropped from the centerfold of the November 1972 issue of Playboy
magazine.
</blockquote>
<a href='https://en.wikipedia.org/wiki/Lenna'>Wikipedia</a>
</div>
</div>
</div>
I'm making a div that I want to say "Banner" with a larger "BANNER" in grey behind it. Kind of like a water-mark. But the positioning is wrong and the browser is rendering the 'water-mark' on top of the banner text.
.banner {
position: absolute;
height: 10%;
width: 100%;
background-color: black;
color: red;
vertical-align: top;
overflow: hidden;
z-index: -1;
}
.wrapper {
position: relative;
height: 100%;
width: 100%;
}
.foreground {
width: 100%;
height: 100%;
font-size: 2em;
margin: 0;
padding: 0;
top: 0;
text-align: center;
z-index: 2;
}
.background {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
top: 0;
text-align: center;
vertical-align: center;
color: lightgrey;
font-size: 7em;
z-index: 1;
}
<div class="banner">
<div class="wrapper">
<div style="position:absolute; width:100%">
<p class="foreground">Banner!</p>
</div>
<div style="position:absolute; width:100%">
<p class="background">BANNER!</p>
</div>
</div>
</div>
For reasons I don't want to go into here, banner needs to keep it's position: absolute (Sorry if that's too restrictive)
Otherwise we're free to play around with it. I would like the water mark to be slightly overflowing from the top and bottom of the banner div or at least flush with the top.
But most importantly I need the water-mark behind the foreground divs content.
Thank for any help! I prefer a CSS solution but JS would be appreciated too. PS here's a jsfiddle if you prefer that.
EDIT I fixed the height issue by putting margin-top:-5% which I tried before, but with a percentage WAY too high. Apparently it goes of the height of the page not it's parent. Perhaps because it's position:absolute. Thanks for your help!
If you want it to appear in a different order, change the order of your html. You can then also get rid of the z-indexes. So:
<div class="banner">
<div class="wrapper">
<div style="position:absolute; width:100%">
<p class="background">BANNER!</p>
</div>
<div style="position:absolute; width:100%">
<p class="foreground">Banner!</p>
</div>
</div>
Alternatively / additionally:
If you need it to be a watermark, why not add some opacity of like 0.3 to .background? That does not actually put it behind the text, but makes it appear like a watermark.
Working in this fiddle: https://jsfiddle.net/0srj5hus/1/
I'm building an web app which has a 100% height/width/fullscreen layout. I am looking for a CSS-trick to proportionally resize an elements dimensions according to its height.
Right now I am looking for an equivalent of what this trick does to the x-axis:
html, body{
height:100%;
margin:0;
}
#view {
min-height: 100%;
position: relative;
width: 100%;
background-color: #333333;
}
#test-hld {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
background-color: tomato;
width: 100%;
height: 75%;
}
.test{
position: relative;
width: 30%;
}
.test:before{
content: "";
display: block;
padding-top: 75%;
}
.content{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: black;
}
<div id="view">
<div id="test-hld">
<div class="test">
<div class="content"></div>
</div>
</div>
</div>
But changing (for example) .test{height: 80%} and .test:before{padding-left: 75%} makes the browser render no dimensions of the box at all.
My question(s) is
Why is the opposite not working?
Has it something fundamental to do with setting heights of elements with CSS?
Can flex/flexbox solve this?
I know it's possible to fix this with some lines of JS but I just can't believe it's not doable with CSS until someone slaps my face telling me to get real.
First of all, just to know why the padding trick works.
Padding-top and padding-bottom are vertical dimensions that are related to the width (so, an horizontal dimension) of the container.
That allows the ratio of an element to be fixed, and related to the width of the container. But there isn't any horizontal dimension that is related to some vertical of the container, so the equivalent trick over the height is not posible right now.
I have tried to get this same result using another technique, but I have had a very partial success.
My failed attempt is try to use an image to set the ratio
body, html {
height: 99%;
}
.base {
height: 40%;
border: solid 1px green;
display: inline-block;
position: relative;
}
.ratio {
content: url("http://placehold.it/400x200");
opacity: 0.05;
height: 100%;
width: auto;
position: relative;
}
<div class="base">
<img class="ratio" />
</div>
This is working in IE and Chrome, and failing in FF. But just on initial loading.
Changing the browser size won't work until the page is reloaded. I just can't figure out why, or how to solve it
I need to space four images aligned horizontally evenly in a row. I am aware that this has been asked many times here, yet none of the solutions I found have worked for me. They all seem to rely on either a fixed width for the row, or a fixed width for the images. I need to specify both in percentages.
My Html:
<div id="tabBar">
<div id="PDiv">
<img id="Person" src="images/icons/tabBar/image0.png">
</div>
<div id="SDiv">
<img id="Sale" src="images/icons/tabBar/image1.png">
</div>
<div id="CtDiv">
<img id="Current" src="images/icons/tabBar/image2.png">
</div>
<div id="FDiv">
<img id="Food" src="images/icons/tabBar/image3.png">
</div>
<span id="Stretch"></span>
</div>
The CSS
#tabBar
{
position: fixed;
bottom: 0;
left: 0;
background-color: #F3F3F3;
width: 100%;
text-align: justify;
}
#PDiv, #SDiv, #CDiv, #FDiv
{
background-color: #F3F3F3;
width: 24%;
vertical-align: top;
height: auto;
display: inline-block;
}
#Stretch
{
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0;
}
The issue with this method is that I am building a mobile hybrid app. Therefore, it will have to work on many screen sizes. Currently it looks great on larger screens and computers, but on phones with smaller-sized screens, either the images begin to get cut off, or one of them goes and makes a new line. Instead, I need the images to just scale down and stay evenly spaced.
Have you tried scaling your images with CSS, like so:
img {
width: 100%;
height: auto;
}
This will prevent you images of creating new lines, or being cut off.
EDIT:
jsfiddle link: http://jsfiddle.net/ATube/
You have a mismatch in your CSS classes (#CtDiv vs #CDiv). This leaves CDiv as a block element.
If I may suggest though... the whole 'stretch' thing is unnecessary and the 24% just puts you into rounding errors. I'd recommend something more like this:
HTML
<div id="tabBar">
<div id="PDiv"></div>
<div id="SDiv"></div>
<div id="CDiv"></div>
<div id="FDiv"></div>
</div>
CSS
#tabBar {
position: fixed;
bottom: 0;
left: 0;
background-color: #F3F3F3;
width: 100%;
height:40px;
}
#PDiv, #SDiv, #CDiv, #FDiv {
background-color:#F3F3F3;
background-size:contain;
background-repeat: no-repeat;
background-position:center center;
width: 25%;
vertical-align: top;
display: inline-block;
float:left;
height:100%;
}
#PDiv {
background-image:url(images/icons/tabBar/image0.png);
}
#SDiv {
background-image:url(images/icons/tabBar/image1.png);
}
#CDiv {
background-image:url(images/icons/tabBar/image2.png);
}
#FDiv {
background-image:url(images/icons/tabBar/image3.png);
}
Generally, this should be somewhat lighter weight, but more importantly... allow you better separation of style and structure.
Even made you a fiddle:
http://jsfiddle.net/F6khC/