I am trying to create a web page that looks like like in this site:
http://dribbble.com/shots/805937-Minimalist-invoice
Overview of why I need the design to be static:
I am trying to create a website that has the same concept as that of an ecommerce website. So every time I update a new item on my list, it will be displayed inside a table and so on.
I tried creating an image with that design using photoshop(the one in the middle with a white background and pointy edges on the top and bottom) but the result is that the image is static and does not dynamically change when the content of the page changes.
I do not know if I can implement the design by customizing the borders using pure HTML code.
I tried using the image-border property of CSS, but it still has horizontal borders on the edges. I also used the background image property, but the result is that it is static and does not change when an update in the items changes.
Thanks for all the help.
Check out this answer.
It uses linear-gradients to produce this effect.
I have updated it a little to suit your question
FIDDLE
I'd do something like:
html:
<div class="invoice">
<div class="topEdge">
</div>
<div class="invoiceContent">
<!--prices or whatever markup you want-->
<p>$1.40</p>
<p>$1.40</p>
<p>$1.40</p>
<p>$1.40</p>
<p>$1.40</p>
<p>$1.40</p>
<p>$1.40</p>
</div>
<div class="bottomEdge">
</div>
</div>
css:
.invoice {
width: 400px;
}
.topEdge {
height: 20px;
background: red; /* replace red with your top edge background image */
}
.bottomEdge {
height: 20px;
background: blue; /* replace blue with your top edge background image */
}
http://jsfiddle.net/KFTzc/
You can solve this in two ways, both including the :before and :after pseudo elements.
1 (Cross browser compatible):
Get a snippet of the zig-zag background, then repeat it along the x axis in the :before and :after pseudo elements of the element you want the zig-zag borders. For example:
.zig-zag-element:after{
content: ' ';
width: 100%;
display: block;
background: url('/path/to/zig-zag.png') repeat-x;
}
2 (CSS3 gradients):
If you use layered linear-gradients on the background like this:
background:
linear-gradient(135deg, #FCFCFB 25%, transparent 25%),
linear-gradient(225deg, #FCFCFB 25%, transparent 25%),
linear-gradient(315deg, #8CCEE8 25%, transparent 25%) -7px 0,
linear-gradient(45deg, #8CCEE8 25%, transparent 25%) -7px 0;
background-size: 14px 14px;
background-color: #DCDCDB;
in combination with the :before and :after pseudo elements you can get the result you are looking for.
Check out this FIDDLE.
NOTE: The example will only work for webkit browsers (since I made it as a proof of concept). If you want other browser support you need to add multiple background properties and add the prefixes.
If you don't care losing support for old browsers, try CSS3 border-image property:
http://css-tricks.com/understanding-border-image/
See When Can I Use for browser support:
http://caniuse.com/#feat=border-image
Otherwise you could add a background to thead and tfooter elements of the table (haven't tried, but this should work). If still no luck with this, try adding an extra element before and after the table element and add background to them.
Related
How can I create a programmatic horizontal gradient that starts at a prescribed location (in pixles on the x-axis)?
Here's the issue- I've got an image set as background-image - ideally, what I'd like to do is declare a CSS gradient that starts close to the edge of the image (~1800 pixels) and fades gracefully to full black.
So far, the best solution I have is to have two div elements- one with the photo background and the other with a 1px tall gradient image repeated along the y-axis with a background-position that starts at 1780px.
This works, but I really want to get away from the 1px image trick. Any ideas?
<div id="photobg">
<div id="gradientbg">
</div>
</div>
#photobg {
background-image:url('photourl.jpg');
}
#gradientbg {
background-image:url('1pxgradient.jpg');
background-repeat: repeat-y;
background-position: 1780px 0;
height: 100%;
}
What I'd like to do, in theory, is use color stops at 1780 px for a CSS gradient but as I understand it, CSS only supports % values as color stops.
Reference:
CSS 3 Gradient n pixels from bottom - Webkit/Safari
No, you can use pixels with linear gradient:
background-image: linear-gradient(transparent 1780px, black 100%);
You can also combine this gradient with multiple background images on one div.
You might want to check out this jsbin, I've made for you:
http://jsbin.com/sonewa/1/edit
This block of css will do what you want
background: -moz-linear-gradient(center top , #00AFF0, #53D4FE); //this is for mozilla
background-image: -webkit-linear-gradient(top, #00AFF0, #53D4FE); //this is for chrome and safari
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00AFF0', endColorstr='#53D4FE', GradientType=0); //this is for IE
while the gradient is from color #00AFF0 to #53D4FE (top to bottom)
I am trying apply two background images for an entire table row. One background image will make my table row look bit bluish and another image will appear on the right most side of table row.
I searched Google and found a small css snippet but it did not work:
.TdStyle{
background-image: url(images/buttonback.png) left repeat,
url(images/down_arrow.png) right no-repeat;
}
Please guide me how to do so.
Not a clean way but the only way that I know:
One of the biggest problems with using the CSS3 Multi-backgrounds is that it is not usable in Internet Explorer, however by using the: AlphaImageLoader IEFilter, it is possible to place two background images in an element.
One advantage to using this IE specific filter is that it retains any alpha transparency that is applied to png's, without the requirement of any htc or javascript 'fixes'. The main disadvantage is that the image displays in the top, left-hand corner, and cannot be positioned.
The CSS3 for multiple backgrounds is achieved via a comma seperated list for the properties:
background-image: url(../images/lakeside2.png),
url(../images/lilys.jpg);
background-position: top left, bottom right;
HTML:
<div id="multipleBackgroundImages">
<p>
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
</p>
<p class="no_colour">
<strong><br />These three paragraphs are inside of a div that has multiple background images</strong>The background color removed.
</p>
<p>
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
This is just some filler content to make the paragraph larger.
</p>
</div>
CSS:
#multipleBackgroundImages {
background-image: url(../images/lakeside2.png),
url(../images/lilys.jpg);
background-position: top left, bottom right;
background-repeat: no-repeat;
border: 1px solid black;
padding: 0 1em;
}
#multipleBackgroundImages .no_colour {
background-color: transparent;
}
#multipleBackgroundImages p+p+p {
background-color: #ffc;
padding: 1em;
}
<!--[if gt IE 7]>
<style type="text/css">
/* The proprietary zoom property gives IE the hasLayout property which addresses several bugs, dont forget to insert your wrappers id */
#outerWrapper #contentWrapper, #outerWrapper #contentWrapper #content {
zoom: 1;
}
/* Now lets make it IE8 Multi-background images */
#multipleBackgroundImages {
background-image: url(../images/lilys.jpg);
background-position: bottom right;
background-repeat: no-repeat;
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/lakeside2.png', sizingMethod='crop')";
border: 1px solid black;
padding: 0 1em;
}
/* Fix for IE clearType */
#multipleBackgroundImages p {
position: relative; /* required to re-enable IE's clearType */
}
</style>
<![endif]-->
For IE6/7 you would use the following for the IE filter:
filter: progid: DXImageTransform. Microsoft. AlphaImageLoader (src='../images/lakeside2.png', sizingMethod='crop');
IE Filter options:
sizingMethod='crop' will retain the image dimensions, if this is changed to, sizingMethod='scale' the image will resize to the size of the element it is applied to, (auto resizable background image!).
Don't forget to change the image file references to point to your images. Naturally this can be applied to any element from the tag to a tag.
Problem: The filter does not apply at all
A filter does solely apply to elements that have "layout", that is the reason for the zoom: 1; property.
If you have multiple "standalone" versions of IE installed, say IE7 side-by-side IE6. The Conditional Comment may not work as intended because the version vector of such a combo is normally the version of the newest browser, i.e. 7.xxxx, therefore, [if lt IE 7] does not match for IE6's parser in this constellation.
IMPORTANT : The IE9 preview has changed how the IE alpha image loader works, (or does not work at all in some cases). If you have the IE9 preview installed it is possible that this 'solution' will appear to not work at all in any version of IE.
Source: http://cookbooks.adobe.com/post_Cross_Browser_Multi_background_images__including_I-16839.html
My suggestion: IE6,IE7 not working in multiple background(i tested).
I'd like to create a simple visual effect for display of rows of data on iPhone/Android/etc, as seen in this example.
The effect is very simple; it's two rectangles on top of each other, the top one lighter than the bottom one and with a lighter-yet border-top. This does it:
<style>
.rowtop { background-color: #333; border-top: 1px solid #ccc; height: 25px; }
.rowbottom { background-color: #000; height: 25px; }
</style>
<div class="row">
<div class="rowtop"> </div>
<div class="rowbottom"> </div>
</div>
Now I'd like to be able to place text and labels on top of this, again as seen in the example. That's where I need help.
I'd like to place the text relative to "row", but row is actually made up of two divs, so it's complicated. The text has to live on top of the "rowtop" and "rowbottom" divs.
I tried messing around with a third div for the labels and setting its z-index but couldn't get it to do what I wanted.
I think I can use a background image instead of rowtop and rowbottom and make it easy on myself, but I was wondering if anyone has a clever non-image based solution.
[Update] Based on edeverett's answer I tried css gradients and they worked great:
background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, rgb(50, 50, 50)), color-stop(50%, rgb(0, 0, 0)));
If you are just targeting mobile browsers you should be able to get that effect using CSS gradients instead of a background image.
As a side note, I think you shouldn't be making this effect by adding extra divs. You should try to keep content and presentation separate in case you (or your users) decide to present it differently in the future. So if CSS gradients don't work for you I'd recommend the background image approach (look at using data-URIs if you want to do something 'fun' and to reduce HTTP requests).
I'm attempting to use a CSS gradient in a div containing some text. With Gecko and Webkit, the text displays fine. In IE7 & IE8 the text appears aliased (jaggy).
I came across this blog stating: "we decided to disable ClearType on elements that use any DXTransform".
IE Blog:
http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx
That was back in 2006; 3.5 years later, I assume this bug would be fixed, but it's not. Is there a way to do this in IE8 without resorting to stuffing a repeating background image in the div?
Here's an example of what I mean.
<style>
div
{ height: 50px;
background: -moz-linear-gradient(top, #fff, #ddd);
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffffff, endColorstr=#ffdddddd);
}
</style>
<div>Hello World</div>
<p>Normal text</p>
In IE, the text in the div is aliased (jaggy), and the text in the paragraph is not.
Any solution that doesn't involve images would be greatly appreciated.
There's no good solution to this problem.
Worse yet: progid:DXImageTransform.Microsoft.gradient is horribly buggy so mouse events (hover, click, etc.) pass right trough it - a click on such an element also triggers a seperate click on whichever element that happens to be positions behind it. Beware!
Regardless, you better start considering which fallbacks/workarounds/NastyHacks feel acceptable to you.
Here are a few ideas off the top of my mind - in order of my personal preference:
Just fall-back to a plain solid background-color in IE and move on with your life. (Be sure to place that background rule first for it to be safely overridden/ignored by FF and Webkit.)
Use a background-image in IE. (Again place that CSS rule at first)
Keep using the gradient hack and simply 'suck it up' and accept the jaggy text for IE.
use Javascript (or IE's proprietary CSS expression() syntax) to inject an empty element, apply the gradient to it and place it behind the text.
div {
background: -moz-linear-gradient(top, #fff, #ddd);
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
behaviour: expression( jQuery(this).wrapInner('<div class="ie-wrap"/>').prepend('<div class="ie-gradient"/>'); this.runtimeStyle.behaviour='none'); /* disable repeat runs */
position: relative;
}
div div.ie-wrap {
position: relative;
}
div div.ie-gradient {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: expression( this.runtimeStyle.height=this.parentNode.clientHeight+"px" );
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffffff, endColorstr=#ffdddddd);
}
(Warning: above code is untested pile of crap. and will probably not work as is.)
Keep using the gradient hack and use Cufon to replace the jaggy text with VML rendered text. (Rests on the assumption that your site is using a typeface that allows font-embedding.)
You could try using an IE css 3 html component, like PIE (http://css3pie.com,) which does a fairly decent job of rendering gradients. (Though this is essentially using javascript)
Wrap the content with a DIV then add this to the DIV's css style...
position: relative;
http://cookbooks.adobe.com/post_IE8_clearType_fix_when_using_filters-16676.html
I had a situation where I wanted backgrounds of text areas to be certain colours fading horizontally to white and defined by hexadecimal in the CSS. I wanted to avoid making colour background images in case a non-developer member of my company wanted to add a new colour with hexadecimal only.
The solution I found was to make a 24-bit PNG of white gradienting into transparent set to the width of the area I was making.
I then used this IE-only hack to get the CSS to render a background colour of my choice that fades to white:
background /*\**/: #CCCED4 url('/white_to_transparent.png') repeat-y top left\9;
(the hack could be improved, but it works for me, including IE9)
I found another inexpensive (bit opaque) solution. The text becomes anti-alised back again, when wrapping the text node and setting each element to relative position. Do not ask why...
Lets assume:
<html>
<head>
<title>IE8 filter problem causing jagged fonts</title>
<style>
html, body, div, span, b, i, ul, li, h1, h2, h3 ... to be continued {
position: relative;
}
.gradient {
filter:
progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#e6e6e6');
}
</style>
</head>
<body>
<div class="gradient">
<div>I am wrapped, therefore not jagged</div>
</div>
</body>
</html>
Hope that helps anyone out there. In this case it's not necessary to use background images or derivates.
Working example in jsfiddle: http://jsfiddle.net/SLZpE/2/
This may not count as elegant (or working) solution, but how about using Cufón for IE?
Yes, that's a problem with IEx.
Try using a solid background color:
/*replace #ccc with the color you want*/
background: url(images/gradient-image.png) top repeat-x #ccc
Now, no need to use the expression "...stuffing a repeating background image", since there's nothing wrong with using a background image and repeat it, we should be thankful that we can not only do that, but we can repeat it in X and Y.
Of course, you want to make your repeating background image as efficient as possible, so make it small/thin (depending on your design) and use it, rest assured, you are not doing anything wrong or against any standards or best practices.
What I am trying to do is to show both background-color and background-image, so that half of my div will cover the right shadow background image, and the other left part will cover the background color.
But when I use background-image, the color disappears.
It's perfectly possible to use both a color and an image as background for an element.
You set the background-color and background-image styles. If the image is smaller than the element, you need to use the background-position style to place it to the right, and to keep it from repeating and covering the entire background you use the background-repeat style:
background-color: green;
background-image: url(images/shadow.gif);
background-position: right;
background-repeat: no-repeat;
Or using the composite style background:
background: green url(images/shadow.gif) right no-repeat;
If you use the composite style background to set both separately, only the last one will be used, that's one possible reason why your color is not visible:
background: green; /* will be ignored */
background: url(images/shadow.gif) right no-repeat;
There is no way to specifically limit the background image to cover only part of the element, so you have to make sure that the image is smaller than the element, or that it has any transparent areas, for the background color to be visible.
To tint an image, you can use CSS3 background to stack images and a linear-gradient. In the example below, I use a linear-gradient with no actual gradient. The browser treats gradients as images (I think it actually generates a bitmap and overlays it) and thus, is actually stacking multiple images.
background: linear-gradient(0deg, rgba(2,173,231,0.5), rgba(2,173,231,0.5)), url(images/mba-grid-5px-bg.png) repeat;
Will yield a graph-paper with light blue tint, if you had the png. Note that the stacking order might work in reverse to your mental model, with the first item being on top.
Excellent documentation by Mozilla, here:
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_multiple_backgrounds
Tool for building the gradients:
http://www.colorzilla.com/gradient-editor/
Note - doesn't work in IE11! I'll post an update when I find out why, since its supposed to.
use
background:red url(../images/samle.jpg) no-repeat left top;
And to add to this answer, make sure the image itself has a transparent background.
Actually there is a way you can use a background color with a background image. In this case, the background part will be filled with that specified color instead of a white/transparent one.
In order to achieve that, you need to set the background property like this:
.bg-image-with-color {
background: url("example.png") no-repeat, #ff0000;
}
Note the comma and the color code after no-repeat; this sets the background color you wish.
I discovered this in this YouTube video, however I'm not affiliated with that channel or video in any means.
Here's an example of using background-image and background-color together:
.box {
background-image: repeating-linear-gradient( -45deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .2) 15px, transparent 15px, transparent 30px);
width: 100px;
height: 100px;
margin: 10px 0 0 10px;
display: inline-block;
}
<div class="box" style="background-color:orange"></div>
<div class="box" style="background-color:green"></div>
<div class="box" style="background-color:blue"></div>
Make half of the image transparent so the background colour is seen through it.
Else simply add another div taking up 50% up the container div and float it either left or right. Then apply either the image or the colour to it.
Gecko has a weird bug where setting the background-color for the html selector will cover up the background-image of the body element even though the body element in effect has a greater z-index and you should be able to see the body's background-image along with the html background-color based purely on simple logic.
Gecko Bug
Avoid the following...
html {background-color: #fff;}
body {background-image: url(example.png);}
Work Around
body {background-color: #fff; background-image: url(example.png);}
Hello everyone I tried another way to combine background-image and background-color together:
HTML
<article><canvas id="color"></canvas></article>
CSS
article {
height: 490px;
background: url("Your IMAGE") no-repeat center cover;
opacity:1;
}
canvas{
width: 100%;
height: 490px;
opacity: 0.9;
}
JAVASCRIPT
window.onload = init();
var canvas, ctx;
function init(){
canvas = document.getElementeById('color');
ctx = canvas.getContext('2d');
ctx.save();
ctx.fillstyle = '#00833d';
ctx.fillRect(0,0,490,490);ctx.restore();
}
Please let me know if it worked for you
Thanks
background:url(directoryName/imageName.extention) bottom left no-repeat;
background-color: red;