I want to make a trapezoid image with css. I've already found some code, but i want a code which makes the trapzeoid shape with transparent left border.
So here you can see that, the left border of the image has been cut down. I want to do that with css. Is it possible?
So i want to make the picture with the man. It is a simple picture and i want to cut down the left border. I tried this
<div class="trapezoidImg"></div>
.trapezoidImg
{
position: absolute;
overflow: hidden;
padding: 0;
margin-left: 100px;
display: inline-block;
width:510px;
height:200px;
background:url('http://iskolaujsag.blathy-bp.hu/wp-content/uploads/2009/04/getattachment-2.jpg');
background-position: center;
-o-background-size: 510px;
-moz-background-size: 510px;
background-size: 510px;
}
.trapezoidImg:after
{
content : "";
position : absolute;
z-index : 2;
left : -50%;
width : 145%;
height : 80%;
display : block;
background : rgb(51,51,59);
bottom: -90%;
-webkit-transform: rotate(55deg);
-moz-transform: rotate(55deg);
transform: rotate(53deg);
}
and it works but the :after tag must have a color, i want a transparent one, but if i set it transparent, the image wont be cut. And the reason why i dont want to edit the images in a photeditor, is its going to be a slider, and i dont want to edit all of the images.
Without any code and any tips of what you want to do in the end, i can go with this idea of gradient and image mixed in the background of a container.
On each side some content ?
Here is a free interpretation of your unclear question, hopping it will make you give us some info usable.
background:
url(http://i.stack.imgur.com/WJ3MT.png) center no-repeat,
linear-gradient(47deg, tomato 50.1%, transparent 50%) left no-repeat,
linear-gradient(47deg, transparent 50%, #333 50.1%) right no-repeat;
Related
I got this background image to be the right size when the page is normal, but when I add enough text that you have to start scrolling, the image doesn't cover the whole page. The image is taller than it shows, but when I change the height, the image just gets bigger, and I can't figure out how to show the rest of the image. Does any one know how to do this?
.bc-grnd-img {
background-image: url("https://media.istockphoto.com/photos/little-cute-dumpy-frog-with-green-background-picture-id694848990?k=20&m=694848990&s=612x612&w=0&h=9tBJzT_Efz0GqI30Je72vvkqtSCQ5Deb_RRCdsG-e0c=");
filter: blur(8px);
-webkit-filter: blur(8px);
height: 500px;
background-position: top;
background-repeat: no-repeat;
background-size: cover;
position: relative;
top: 0px;
z-index: -1;
}
<div class="bc-grnd-img"></div>
You have wrong in css
we don't use link for image, download image
.main{
width: 100%;
background: linear-gradient(to top,
rgba(0,0,0,0.5)50%,rgba(0,0,0,0.5)50%), url(1.jpg);
background-position: center;
background-size: cover;
height: 109vh;
}
Your CSS is very heavy and will lead to a slow website in the end, use Photoshop or Photopea to make sure your image is 1920px wide, it can be as tall as you like but remember the larger the image the slower the internet!
This code should then suit.....
background: url("img-name.jpg") 50% 50% no-repeat;
background-size: cover;
50/50 should keep your image centered no matter how tall it is and for a static background we perhaps wouldn't want that repeating.
As a bonus, this also works good for Parallax backgrounds but the image should then definitely be taller than the display area.
Please check out this website template http://www.gt3themes.com/website-templates/timber/#. I am trying to recreate the effect they do on the masthead image with the wood background. They create a slanted bottom on the background image without any css transforms or anything. They use a border of 3000px on the left side and 150px on the bottom. However, I am unsure how the 3000px border on the left creates the effect. If I reduce the left border, then the slant goes away. Can anyone explain how they are creating this effect? Thanks.
They are using a png that is added with css to sit on top of the image:
http://www.gt3themes.com/website-templates/timber/images/sliderL.png
.headerLine:after {
content: "";
position: absolute;
z-index: 1;
pointer-events: none;
bottom: 0;
left: 0;
width: 100%;
/* background: url(../images/sliderL.png) center center no-repeat; */
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
border-bottom: 150px solid white;
border-left: 3000px solid transparent;
}
Change the css to
.line2:after {
content: "";
position: absolute;
z-index: 1;
pointer-events: none;
bottom: 0;
left: 0;
width: 100%;
/* height: 240px; */
/* background: url(../images/sliderL.png) center center no-repeat; */
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
border-bottom: 150px solid rgb(56, 156, 38);
border-left: 3000px solid rgba(146, 31, 31, 0.89);
}
And you will see the trick. It's a classic border triangle. The border bottom is originally white, and is hiding the bottom of the image . the border left is transparent, and is needed to create the triangle effect.
The borders applied to the :after element is key here. Essentially, an element has 4 border points - top, bottom, left and right. If you imagine the borders on an element like you would the borders of a picture frame you'll find that the connecting point of each of these borders is at the edges of the element. Nothing special there. But when you increase the size of the borders, you'll notice that if the border has equal width on all the sides, the connecting points are at an angle and forms a straight line from the inner edge of the element to the outer edge.
This JSFiddle will give you an idea of what I'm talking about: http://jsfiddle.net/dzul1983/d8fvfuLs/
We can create triangles simply by manipulating the border widths, as demonstrated here: http://jsfiddle.net/dzul1983/d8fvfuLs/3/
So by manipulating the left and bottom borders, we can replicate the effects seen on the Timber page. You should now have an idea of how it works, and understand what you need to do to replicate this effect for your purposes.
Probably one of the most documented subjects and yet I can't seem to find a proper answer for what I'm trying to get accomplished.
I have a sprite containing two images on top of each other. I only want to show the green one and have it be responsive at the same time. It is the background image of the whole page.
Please see: http://demo.chilipress.com/epic3/
I've given it a height: 900px because that's half of the height of the full img. I know it's not responsive as it is now.
HTML:
<div id="background_contact"></div>
CSS:
#background_contact{
background-image: url('bg_contact.jpg');
width:100%;
height: 900px;
background-position: 0 0;
background-size: 100%;
display: block;
}
An example is to have a hover effect on it, but you get the idea.
#background_contact:hover {
background-position: 0% 100%;
}
If you don't mind the stretch, you can adjust your CSS to cover everything.
#background_contact {
background-size: 100% 200%;
}
If you don't want it to stretch, you can use the following CSS, though you may want your own background color filler for the gaps:
#background_contact {
background-size: auto 200%;
background-position: 50% 0;
}
#background_contact:hover {
background-position: 50% 100%;
}
I have done a bit of googling and can't way a way to stop my background images overlapping. What I'm trying to do is have a div with a faded background. But when the fade reachs full opacity I want to apply a different background image that can repeat so the div looks flawless no matter how long the div is.
I have thought about just applying full length images for each web page but I would rather have this working so I don't need to worry about how much content I can apply to each page.
#content_holder{
width:800px;
height:1000px;
background-image:url(../images/PC/content_top.png),url(../images/PC/content_bottom.png);
background-position:0 0,0 240px;
background-repeat:no-repeat,repeat-y;
}
Added note: the height says 1000px, this is purely for testing purposes as the div is empty at the moment.
The second image does repeat but starts form the top of the div overlapping the other image.
these are the images:
content-top.png show once
content-bottom.png repeat after content-top
Whats happening:
What about just removing background-position and adjust the background-repeat:
background-repeat: repeat-x, repeat;
jsFiddle
edit
Hmm, multiple background just works like this. It's overlaying because the border underneath it is has the full height(it's repeating). A background doesn't see a other background as a boundry. You can do two things:
Make the boundry with a seperate element, so one element for the top
background and one for the bottom background.
You can edit the image to make the transition more smooth, thus you can't really see the border does overlap(a semi-transparent image makes a smooth transition easy)
#content_holder{
width:800px;
height:1000px;
background-color:rgba(0,0,0,.65);
position: relative;
z-index: 2;
background: url(http://i.stack.imgur.com/j3THB.png) top left no-repeat, url(http://i.stack.imgur.com/35j7u.png) bottom left no-repeat;
}
#content_holder:before{
content: '';
position: absolute;
z-index: -1;
top: 240px;
right: 0;
bottom: 0px;
left: 0;
background: url(http://i.stack.imgur.com/35j7u.png) top left repeat-y;
}
Solved it not entirely sure on a full explanation but it works find this post, it was quite similar to mine.
JSFIDDLE
A radical but effective way to deal with this if you have a known max height and you are already in a ":before":
&:before {
background: url('vertical-line.png') no-repeat 0px,
url('vertical-line-repeat.png') no-repeat 140px,
url('vertical-line-repeat.png') no-repeat 200px,
url('vertical-line-repeat.png') no-repeat 260px,
url('vertical-line-repeat.png') no-repeat 320px,
url('vertical-line-repeat.png') no-repeat 380px,
url('vertical-line-repeat.png') no-repeat 440px,
url('vertical-line-repeat.png') no-repeat 500px,
url('vertical-line-repeat.png') no-repeat 560px,
url('vertical-line-repeat.png') no-repeat 620px,
url('vertical-line-repeat.png') no-repeat 680px,
url('vertical-line-repeat.png') no-repeat 740px;
}
I am working on this site: http://www.problemio.com and I have a requirement to add the background image to the top banner which I did.
What I can't figure out how to do is how to shift it all the way to the right and make it smaller in length so that it only takes up half of the screen width.
Any idea how to do that? So far I have this css for the overall banner div:
.banner
{
width:60em;
margin: 0 auto;
position: relative;
padding: 0.3em 0;
z-index: 1;
background-image: url('http://www.problemio.com/img/ui/problemiotoprightimage.png');
background-repeat: no-repeat;
background-image: right-align
}
but I don't know how to make the background image align right and rescale to be 50% of the entire width of the div. Any ideas?
Thanks!
You can use left, right, bottom, top and center for aligning backgrounds. Also percentages.
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') right no-repeat;
However, you cannot resize the images using CSS2 but in CSS3.
background-size: <width> <height>;
More usage:
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') top right no-repeat;
To align bottom and centered:
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') bottom center no-repeat;
Use background-position: right; and background-size: [width] [height] (replace values where needed).