I am using box-shadow to mimic an inset border for a series of divs. The problem is the box-shadow doubles in pixels at the top/bottom of each div because they are stacked.
Is there a way to perhaps cut the top/bottom border dimension in half…so when stacked it equals the left/right?
Thanks for the reply…your approach doesn't seem to solve the problem though. If you remove the margin-bottom in your example…we end up with the same result. In the case of my example, there should be no margin.
I've partially found a solution using your method, but it only works when I remove display: table. Unfortunately I need to keep display: table because other elements (not shown) use disply: table-cell and depend on the parent. The border is applied outside the element when display: table is used.
They do look similar…but there is a slight difference. The example without display: table has an inset border, while the example with display: table does not. The Inset border is the desired output.
Hello everyone,
I am using box-shadow to mimic an inset border for a series of divs. The problem is the box-shadow doubles in pixels at the top/bottom of each div because they are stacked.
Is there a way to perhaps cut the top/bottom border dimension in half…so when stacked it equals the left/right?
Example: http://tinker.io/6f2b5
Note: if anyone has a better approach for accomplishing an inset border…I'm all ears.
Thanks
If you use: box-sizing: border box; then your padding and borders will not exceed the limits of your overall dimensions.
http://codepen.io/nordstromdesign/pen/awegv
@nordstromdesign
Thanks for the reply…your approach doesn't seem to solve the problem though. If you remove the margin-bottom in your example…we end up with the same result. In the case of my example, there should be no margin.
Example Update: http://tinker.io/6f2b5/1
I made some adjustments:
http://codepen.io/nordstromdesign/pen/awegv
@nordstromdesign
I've partially found a solution using your method, but it only works when I remove display: table. Unfortunately I need to keep display: table because other elements (not shown) use disply: table-cell and depend on the parent. The border is applied outside the element when display: table is used.
Example without (display: table) http://tinker.io/6f2b5/2
Example with (display: table) http://tinker.io/6f2b5/4
how about adding something like this:
@wolfcry911
Still doesn't correct anything. I think the problem now depends on the display: table
Your last two examples, with and without
display: table, looks the same to me.@crocodillon
They do look similar…but there is a slight difference. The example without display: table has an inset border, while the example with display: table does not. The Inset border is the desired output.
works for me...
@wolfcry911
I'm not picking up what you're throwing down. Would you mind posting an updated working sample please?
http://tinker.io/6f2b5/6
@wolfcry911
I see now. Please excuse my ignorance, but can you please explain what the following is called and generally used for? Thanks
div~div { }http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/
@paulie_d
thanks!
EDIT: I'm looking for something similar to the posted article, but for html5 and jquery. Do you have any recommendations?