Setting Image for border-bottom property - css

We all know that
border-bottom: 2px solid #000;
will make the bottom border 2px thick and color will be black
but can we do any such thing like for the border bottom we can set an image
that means a thin horizontal image will be the bottom-line border of the div??
thanks in advance

border-image, might be what you seek, but it`s CSS3. See http://www.w3schools.com/cssref/css3_pr_border-image.asp .
I would set positon:relative; on the container <div> and use position:absolute; bottom:0; for your <img /> inside the container.

You can emulate the image border-bottom by setting the image by something like
background: url(...) bottom repeat-x;
or
background: url(...) bottom no-repeat;
background-size: 100% 3px;
Unlike the actual border-image, this will work in IE (IE7+ for the first example, IE9+ for the latter one).

Related

why isnt this background-origin working?

I'm messing around with the background origin property buy it doesnt seem to be working why? From my understanding background-origin dictates the paint area of the box-model, I would assume this should show the blue padding but it's not and I'm sure what it is that I'm doing wrong.
https://jsfiddle.net/36trf972/18/
div{
background-color: blue;
width: 100px;
height: 100px;
border: 5px dashed red;
padding: 10px;
background-clip: border-box;
background-origin: content-box;//not working-why?
background-size: cover;
background-position: center;
background-image: url("panda.jpg");
}
Use px instead of center.
I use background-repeat:no-repeat; for you to see result better.
div{
background-color: blue;
width: 100px;
height: 100px;
border: 5px dashed red;
padding: 10px;
background-clip: border-box;
background-origin: content-box;//not working-why?
background-size: cover;
background-position:50px 50px;
background-repeat:no-repeat;
background-image: url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUSEhIVFhUVFxcYFhgWGBUYFxcYFRgWFxgXFhcYHSggGBolHRUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGi0lHSUrLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAMABBwMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAEAQIDBQYHAAj/xABBEAABAwIDBQUGBAUDAgcAAAABAAIRAyEEEjEFQVFhcQYigZGhEzKxwdHwFEJS4QcVI2KSM3LxU6IWQ2OCk6Oy/8QAG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ztN11cYGsjTCTLWqyRYwQZH0ReWwcNDryPBCU6ibUquaczbj8zeI5KSbW0FegtQY6mC0yY5BLSxDHtzNNt43hNr1LWj5olJNWikzHurvpVAKbcjJuXHlqdxOsSQORiFf1q1HGUSxxa5zbSePC+h5cxKqu0FIPZeQAe8W6x1JgdfsZF20DTHd7tNpEAEgHeGNOsfmc7U+IQhplxQ2EylUhzbTF+s/JXWz8PSZ3gBwPMxElZLaHadxa0uvMjNEEzdxHAAZR48kuH24YAB3mztCAGTfxQNtFmr2hQbY5dDaNR9UPUgjO0XbrHx6LP4ztGAAM3dc3MOlx5iEHgu0AbU9p3i3So0fpP5gPXw5pE4OW0BOCewrbOJc4ENuG3IHnIi4/e6ytY7xIn1Rm3ans6pbTcSwgOY6dWuEi/jHgql1QnVOinQ1ztCspkuDWiSdI3rQbP2Sxl6kOdw/K36oPZDgxpf+YyOg5KarVceQKXlk38qM85N6Rb1totbbU8AoW4uo+wsOX1VR+Jpt1Mnlc/RPpbVcTFMBgGrnXgceCy/+f2X5YHp2afCYcxJUeJ2tQZOaoCeDe8fRUNTHvMhn9QQA575a3nlOYBo8ioGsw0gPdkM60cz2jrn+RKFdGu83/gtYF5ZbHtPLgylTMkgAuPHkPqoK22ahzPfUIpy4U2sgGpBt3tQ3STzgX0dnw2cBjARF3tLJHH+mLx0RVXZTTldDXCBlNnAt3RyR8MWP9H+y2oQe0ZTFYt1Rxc8yfQchwUAK2D8LWg+yeGkbvZ048w2R6qnxm08ZTdlfVe0+AkcRAuFshPkvl/7+BsZRl2ZVCk79LvIohmDqHSlU8GO+ik/nWIOtep/kUv81rj/AM+r/wDI/wCqP5g9ArmefA2I5KWjUUJqEmTcnfvlOARAhLahBV5gqpEXtx1HRU1A7tFYYUxu6EfNF4Cg6ZqMFXgyR5aJEFSJAF929eWCcNnYhLR//9k=");
}
<div></div>
You need to remove the property:
background-size: cover;
Cover tells the browser to make sure the image always covers the entire container, even if it has to stretch the image or cut a little bit off one of the edges.
Also, add:
background-repeat:no-repeat;
To prevent any repetition.
When working with background-origin it's important to understand what it does (and what it doesn't do), to get the expected results.
background-origin specifies whether positioning of the background image should be relative to the padding box, border box, or content box. It does not crop or hide any part of the image. (That's what background-crop is for.)
So background-origin is actually behaving as expected your example:
background-origin: content-box // position relative to content box
background-position: center // position center of image at center of content
The image center is positioned at the center of the content box. From there it extends to all sides.
It happens to be that in your example, the center of the content box is the exact same spot as center of padding box or border box, because you have equal widths for border and padding on all sides.
Don't use the background-repeat:repeat along with the background-origin:content-box ..It just won't work.
For all other background-origin such as border-box and the padding-box the repeat option would work just perfectly fine..
If you are trying to fill the content with the background the only option for you is use cover in  background-size..
The best solution comes if you are willing to write an extra piece of code in html by just giving a container element like div for all the content that you need and just fill it with the background..

Transparent border over image

I am trying to create a transparent border for my image and place it over the image using CSS.
For example please see the image below:
To achieve this I tried the following code but I am facing the following problems:
The border is not over the image; its around the image and not allowing the image to fit 100% inside the parent div
To Make the border transparent I used "opacity" but its making the image transparent too which I don't want.
You can check the code live here: http://jsfiddle.net/6GK45/
I could create a div and made the border color transparent and then place it over the image but the problem is the width of my image is fixed (277px) but the height is not. So this will not work for me.
Could you please tell me how to create the transparent image border and place it over the image just like in the image above.?
HTML:
<div class="box" >
<img class="lightbox" src="myimage.jpg" />
This is text
</div>
CSS
.box {
width:277px;
background:#FCFBDF;
}
.lightbox {
border: 5px solid red;
z-index:999;
opacity:0.3;
}
img {
width:277px;
}
How's this - it uses :after to create a pseudo-element which places the border on top of the image, not outside it. http://jsfiddle.net/6GK45/8/
.imgWrap:after{
content:"";
position:absolute;
top:0; bottom:0; left:0; right:0;
opacity:0.5;
border:5px solid red;
}
UPDATE: If it's important to preserve the ability to right-click on the image, you can do it like this with an additional wrapper: http://jsfiddle.net/6GK45/24/
For anyone still googling for this: It is possible to achieve this effect with CSS only by using the outline property:
img {
outline: 15px solid rgba(255, 0, 0, .75);
outline-offset: -15px;
}
<img src="http://i.dailymail.co.uk/i/pix/2012/12/04/article-2242647-0F79C42300000578-201_634x429.jpg" width=250 />
As Donovan said, rgba for the border-color – but the border on an element containing the image, and then the image “pulled” outwards under the border using a negative margin and z-index – like this, http://jsfiddle.net/6GK45/7/
<div class="box" >
<span class="lightbox"><img …></span>
…
</div>
.lightbox{
display:block;
width:267px;
border:5px solid rgba(255,255,255,.75);
}
.lightbox img{
display:block;
width:277px;
margin:-5px;
position:relative;
z-index:-1;
}
If you want a border with opacity, you can use RGBA code. The 'A' signify alpha, so you can modify opacity.
border: 5px solid rgba(255,0,0, 0.3) ;
You can use z-index to put your box with border above your image if you put image and box in position absolute, relative.
I updated your fiddle. http://jsfiddle.net/6GK45/21/
What you need to do is set the image as the background of the parent div and then adjust the width/height of the child div to hug the image accordingly.
//make js fiddle work

background gradient with solid color

I have to do the following:
The top of the div is an image of a gradient, then in the bottom it continues as a solid color. Can I do this with simple CSS? I know the following is invalid.
{background: url(img/right_column_bg_top.png) no-repeat rgba(10,26,39,1) top 225px;
Note: the first 225px, which the image fills, should be without the background-color
As far as I know, you need to use a gradient for the solid color, so that you can set it correctly.
The CSS would be:
.imgbg {
width:255px;
height:355px;
background: url('http://blue2.hu/danone/nogravity/img/right_column_bg_top.png'), linear-gradient(90deg, #f7d8e8, #f7d8e8);
background-position: 0px 0px, 0px 112px;
background-repeat: no-repeat, no-repeat;
background-size: 255px 112px, 255px 233px;
}
Here is your updated fiddle
Basic suport should be fine for browsers supporting multiple backgrounds, the only problem would be with IE <= 8. Gradient background could be a problem with IE9, but I think that it should work (I can not test IE9). If it would be really a problem, see colozilla for a fix.
Check out this fiddle and tell me if this is what you want.
FIDDLE
HTML
<div class="imgbg"></div>
CSS
.imgbg {
width:255px;
height:355px;
background:#f7d8e8 url('http://placehold.it/255x255') no-repeat;
}
I would do the following:
#myDiv { background: #f7d8e8 url('/img/right_column_bg_top.png') repeat-x ; }
This will just put your background image on the top of the div; the rest of it, will be the color you selected for the entire background of the div.

CSS: Extend an image

I have an image that looks like this:
Is it possible to extend this image (perhaps inside a div) so that it would look something like this:
Thanks!
You can create a div of the same color using the CSS background-color property (I believe the hex should be ~#999). Then, position the image as a background-image within the div using the background-position: right property.
HTML
<div class="arrow">Home</div>​
CSS
#arrow {
background-color: #999;
background-image: url('http://i.stack.imgur.com/QDCz4.png');
background-position: right;
background-repeat: no-repeat;
/* sets div dimensions/text styles */
height: 24px;
color: white;
text-align: center;
line-height: 24px;
float: left;
padding-left: 20px;
padding-right: 30px; /* slightly longer to account for background image /*
}
JS Fiddle: http://jsfiddle.net/fbBsz/14/
Get a vertical slice of the gray part of very top left of the arrow with having width:1px. Take that one px slice image and repeat it on -x.
Here is something you can practice with
Since your image does not have a gradient, you have a better chance of matching the color(s) you want with just using background color.
you can set it as a background to a div
#elem {
display:block;
width:200px;
height:20x;
background: url(/filepath/to/image.gif) right top no-repeat #ccc;
}
Just make sure the background color is the same as the dark grey on the gif
No, this is not possible in CSS. You must set the width of the containing element, set the background image's url and set the x-position to right and set the repeat to no-repeat. Then set the background color to the same as the button's foreground color. If the button foreground is a pattern, you will have to use another image as the background.
No, not with that image at least :-)
Looks like you could make use the "sliding doors" technique – see http://www.alistapart.com/articles/slidingdoors/ for a good article about it

CSS problem with spacing

I have a table, in the Table header (TH) I have a background with CSS:
.gridView th
{
padding-top: 1px;
background-image: url('/Images/Design/New/mitte-tb_02.gif');
background-repeat: repeat-x;
background-position: 0px 0px;
color: #FFFFFF;
border: 1px solid Gray;
text-align: center;
}
Now I will right an left from the border 1px space between border and background.
I try all, but it seems useless.
any ideas?
You can achieve this by setting border-collapse on the table to separate and the background colour of the table to Gray. Then set the border of the cells to the colour that you want between the gray border and the background image. See this example: http://jsfiddle.net/NMx5M/
You can put inner div in th element and set background for it with with margin: 0 1px;. An example (I replaced image with color for simplicity).
If I understand you correctly:
By the nature of "background", the image will fill as much of the space as the image size permits (especially if it repeats).
You could force a border using cellspacing or a white border for a visual impression.
Alternatively you will want to make the background image exactly 1px too small around the edges, and position the background absolutely to give the ~impression~ of the gap.
edit
you can perhaps do something like this
.foo {
background: url(bg.jpg) repeat-x;
display:block;
width:99%;
height:99%;
}
<th style="padding:1px;" scope="col"><span class="foo">Foo Bar</span></th>
b

Resources