background image in skewed div - html

having a problem here. I have a got my skewed div perfect but now I want the image to fit in it without tiling so if anyone can help that would be awesome.
I'm going for this:
And so far I have this:
HTML
<div class="box"></div>
CSS
.box {
position:relative;
width:100%;
height:500px;
background: url(../images/clouds.jpeg);
background-size:contain;
padding:10px;
margin-bottom:100px;
}
.box:after {
position:absolute;
content:'';
width:100%;
height:100%;
top:0;
left:0;
right:0;
background:inherit;
background-size:contain;
transform-origin: top left;
transform:skewY(10deg);
z-index: -1;
}

You should use background-size: cover if you want the img to fill the entire container, and then use background-repeat: no-repeatto have one image.
Something like that should work:
.box {
position:relative;
width:100%;
height:500px;
background: url(../images/clouds.jpeg);
background-size:cover;
background-repeat: no-repeat;
padding:10px;
margin-bottom:100px;
}

That image is not skewed..
div{
display:inline-block;
margin:10px;
postion:relative;
width:100px;
height:100px;
background:cyan;
}
div.covered{
background:
linear-gradient(20deg,white,white,40px,transparent 40px,transparent),cyan;
}
<div>
normal
</div>
<div class="covered">
covered
</div>
Bottom-left part can be done by covering image with white color with tilted linear gradient.

Related

CSS clip-circle an image and put another image as border

Similair question can be found here:
CSS: How to fit an image in a circle where bottom is clipped but top pops out?
However, I would like to have the red outline replaced by an image, e.g.:
I tried among others :before and :after psuedo tags but did not find the soluition. Which direction I should look to achieve this?
You can use multiple background like this:
.box {
width:200px;
height:210px;
border-radius: 0 0 50% 50%/0 0 70% 70%;
background:
url(https://i.stack.imgur.com/bdZeE.png) center/cover,
url(https://i.stack.imgur.com/i7iHM.png) 0 180%/100% auto no-repeat;
position:relative;
}
.box:after {
content:"";
position:absolute;
z-index:1;
bottom:0;
top:50%;
left:0;
right:0;
background:url(https://i.stack.imgur.com/i7iHM.png) 0 90%/100% auto no-repeat;
}
<div class="box">
</div>
You can also control the image inside using CSS variable:
.box {
width:200px;
height:210px;
border-radius: 0 0 50% 50%/0 0 70% 70%;
background:
var(--image) center/cover,
url(https://i.stack.imgur.com/i7iHM.png) 0 180%/100% auto no-repeat;
position:relative;
display:inline-block;
}
.box:after {
content:"";
position:absolute;
z-index:1;
bottom:0;
top:50%;
left:0;
right:0;
background:url(https://i.stack.imgur.com/i7iHM.png) 0 90%/100% auto no-repeat;
}
<div class="box" style="--image:url(https://i.stack.imgur.com/bdZeE.png)">
</div>
<div class="box" style="--image:url(https://i.stack.imgur.com/7A8fP.png)">
</div>

CSS proportionally background

i want to implement a proportional background image.
this code i have try but then the scrolling doesnt works and the other divs are in background and not visible?
.background {
background-image:url(xx);
background-position:50% 50%;
background-size:cover;
position:fixed;
left:0;
top:0;
right:0;
bottom:0;
}
Have you maybe a better idea?
Thanks
If you try to fix the div behind the other elements you have to send it via z-index.
.background
{
background-image:url(xx);
background-position:50% 50%;
background-size:cover;
position:fixed;
left:0;
top:0;
right:0;
bottom:0;
width:100%;
height:100%;
z-index:-1;
}
The z-index will set the z axis less than the others. And you'll be able to set it like background.
Add following to your background class
z-index: -1;
width: 100%;
height: 100%;

Repeating background image

I want to put my picture in the background to take the entire screen but image is not repeating.
Screenshot
<div id="backgrounddiv">
<img id="background" src="http://i.imgur.com/nhQAcos.jpg">
</div>
#background {
width:100%;
height:100%;
image-repeat: repeat;
}
#backgrounddiv {
position: absolute;
z-index:0;
left:0;
top:0;
width:100%;
height:100%
}
What you want to be using is background-repeat
The css syntax:
background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;
So it should look like this:
div {
background-image:url(http://i.imgur.com/nhQAcos.jpg);
background-repeat:initial;
}
or if you want it to repeat vertically...
div {
background-image:url(http://i.imgur.com/nhQAcos.jpg);
background-repeat:repeat-y;
}

CSS auto margin is not working for absolutely-positioned element

All the other divs worked well but when i got to this point it does not want to center it for some reason? I'm i missing something?
Take a look at the image link. The menu items is what i want to set the auto margins to. The margin for the ehigh works but not the sides.
http://i.imgur.com/PckN9jX.jpg
.Menuitems {
position:absolute;
margin: 120px auto;
width:398px;
height:26px;
z-index:11;
border-style: solid;
}
#mitem1 {
position:absolute;
background-image:url(http://i.imgur.com/cyKwZQj.png);
background-repeat:no-repeat;
background-position:center;
top:0;
left:0;
width:75px;
height:26px;
z-index:6
}
#mitem1:hover {
background-image:url(http://i.imgur.com/BMHScgr.png);
background-repeat:no-repeat;
background-position:center
}
#mitem1:active {
background-image:url(http://i.imgur.com/4Y4sMtq.png);
background-repeat:no-repeat;
background-position:center
}
#mitem2 {
position:absolute;
background-image:url(http://i.imgur.com/GiAoMqC.png);
background-repeat:no-repeat;
background-position:center;
top:0;
left:77px;
width:75px;
height:26px;
z-index:7
}
#mitem2:hover {
background-image:url(http://i.imgur.com/XQKv9yC.png);
background-repeat:no-repeat;
background-position:center
}
#mitem2:active {
background-image:url(http://i.imgur.com/KQ07YMK.png);
background-repeat:no-repeat;
background-position:center
}
#mitem3 {
position:absolute;
background-image:url(http://i.imgur.com/UPERy0F.png);
background-repeat:no-repeat;
background-position:center;
top:0;
left:154px;
width:90px;
height:26px;
z-index:8
}
#mitem3:hover {
background-image:url(http://i.imgur.com/EqkUtsr.png);
background-repeat:no-repeat;
background-position:center
}
#mitem3:active {
background-image:url(http://i.imgur.com/k54mb7V.png);
background-repeat:no-repeat;
background-position:center
}
#mitem4 {
position:absolute;
background-image:url(http://i.imgur.com/QHExEjQ.png);
background-repeat:no-repeat;
background-position:center;
top:0;
left:246px;
width:75px;
height:26px;
z-index:8
}
#mitem4:hover {
background-image:url(http://i.imgur.com/BjKCQbw.png);
background-repeat:no-repeat;
background-position:center
}
#mitem4:active {
background-image:url(http://i.imgur.com/EVwDUoB.png);
background-repeat:no-repeat;
background-position:center
}
#mitem5 {
position:absolute;
background-image:url(http://i.imgur.com/oKrhDAE.png);
background-repeat:no-repeat;
background-position:center;
top:0;
left:323px;
width:75px;
height:26px;
z-index:8
}
#mitem5:hover {
background-image:url(http://i.imgur.com/gnLuhed.png);
background-repeat:no-repeat;
background-position:center
}
#mitem5:active {
background-image:url(http://i.imgur.com/iqFh66v.png);
background-repeat:no-repeat;
background-position:center
}
#menuline {
position:absolute;
background-image:url(http://i.imgur.com/4xOPK1I.png);
background-repeat:no-repeat;
background-position:center;
left:75px;
top:0;
width:2px;
height:26px
}
#menuline2 {
position:absolute;
background-image:url(http://i.imgur.com/4xOPK1I.png);
background-repeat:no-repeat;
background-position:center;
left:152px;
top:0;
width:2px;
height:26px
}
#menuline3 {
position:absolute;
background-image:url(http://i.imgur.com/4xOPK1I.png);
background-repeat:no-repeat;
background-position:center;
left:244px;
top:0;
width:2px;
height:26px
}
#menuline4 {
position:absolute;
background-image:url(http://i.imgur.com/4xOPK1I.png);
background-repeat:no-repeat;
background-position:center;
left:321px;
top:0;
width:2px;
height:26px
}
<div class="topbox">
<!-- Menu Items -->
<div class="Menuitems">
<a href="#">
<div id="mitem1"></div></a> <a href="shows.html">
<div id="mitem2"></div></a> <a href="codes.html">
<div id="mitem3"></div></a> <a href="about.html">
<div id="mitem4"></div></a> <a href="contact.html">
<div id="mitem5"></div></a>
<div id="menuline"></div>
<div id="menuline2"></div>
<div id="menuline3"></div>
<div id="menuline4"></div>
</div>
<a href="#">
<div class="divlogo"></div>
</a>
</div>
The absolute positioning takes it out of the flow of the page and causes the centering from the auto margins not to work.
.topbox {
position:absolute;
width:100%;
z-index:11;
}
.Menuitems {
margin: 120px auto;
width:398px;
height:26px;
border-style: solid;
}
Will get the menu div positioned correctly. Get rid of all the absolute position on your menu items.
I made this Plunker it might be what you're looking for. http://plnkr.co/edit/wcRaJqvg0fsPT9HcBynf?p=preview
Block level elements are greedy. They use margins to take up the entire horizontal space they're in so that nothing is inline with them. If you set auto on both left and right then both sides want all the space, so they share - resulting in a centred object.
If you use position:absolute or fixed on a block level element it removes this greedy behaviour from the element.
Change the position of .Menuitems to relative and that should fix the issue.

Content flow under image CSS

Ok I have a background that has a clear area that I have balanced content inside and I want it to slide under the top of the image when the user scrolls it up. I have a jsfiddle with it, excuse my sloppy css I have been trying everything to get this to work. I also have a floating nav bar that it should slide under also.
http://jsfiddle.net/CFFwA/
#charset "UTF-8";
/* CSS Document */
html,body {
height:100%;
width:100%;
}
body{
background-image:url(images/1920w.png);
background-size:100%;
background-position:center;
background-attachment:fixed;
background-repeat:no-repeat;
background-color:#E9C9A0;
z-index:5;
}
#bod{
width:100%;
height:100%;
background-image:url(images/1920w.png);
background-size:100%;
background-position:center;
background-attachment:fixed;
background-repeat:no-repeat;
left:0;
z-index:20;
}
#bann{
width:62.5%;
height:100%;
z-index:10;
}
#head{
position:fixed;
margin-top:8.5%;
margin-right:18.75%;
margin-left:18.75%;
width:62.5%;
height:100%;
z-index:32;
}
#content{
padding-top:14%;
width:62.5%%;
height:100%;
margin-left:auto;
margin-right:auto;
z-index:4;
}
An easy fix would be to make your image a separate element with position:fixed
HTML
<img src="/path/to/bg.png" id="body-bg" />
CSS
#body-bg {
width: 100%;
position: fixed;
top: 0;
}
Check the fiddle