table cell background color and round corners - html

In the snippet http://jsfiddle.net/hXMLF/3/ you see a small border on the corners between the white border of the cells and the page background. How can I prevent it?
HTML
<table cellspacing="0" cellpadding="0">
<tr>
<td>Test</td>
<td>Test</td>
</tr>
</table>​
CSS
body {
background-color: #efefef;
}
table {
margin: 10px;
border-collapse: separate;
border-spacing: 0px;
}
td {
border-radius: 5px;
background-color: #369;
color: white;
border: 5px solid white;
}​

There are two solutions I came up with. Use solution 2 but I'm keeping solution 1 here as well because it may come in handy in some other situation to someone else.
Solution 1: Display
Changing td display to inline-block does the trick but may impact your actual content elsewhere...
td {
display: inline-block; /* this has been added */
border-radius: 5px;
background-color: #369;
color: white;
border: 5px solid white;
}​
Here's your changed JSFiddle for solution 1.
Solution 2: Background clip (recommended)
But since you're using CSS3 anyway this is an even better solution:
td {
background-clip: padding-box; /* this has been added */
border-radius: 5px;
background-color: #369;
color: white;
border: 5px solid white;
}​
Here's your changed JSFiddle for solution 2.
If it doesn't work on all browsers, you should be aware that there are browser specific settings as -moz-background-clip and -webkit-background-clip that use a different set of values (they basically omit box from border-box, padding-box and content-box)

This happens because
border-collapse: separate;
makes it like that. Tables aren't exactly the prima donna at styling, I recommend You try to use <div> tags instead.
TRY THIS: http://jsfiddle.net/hXMLF/9/

Check this link. You can generate CSS for round corner cell.
http://cssround.com/
Example:
<div
style="
width:400px;
height:300px;
-webkit-border-radius: 0px 26px 0px 0px;
-moz-border-radius: 0px 26px 0px 0px;
border-radius: 0px 26px 0px 0px;
background-color:#C2E3BF;
-webkit-box-shadow: #B3B3B3 2px 2px 2px;
-moz-box-shadow: #B3B3B3 2px 2px 2px;
box-shadow: #B3B3B3 2px 2px 2px;
">
Just modify width and height values to get what you need...
</div>

Related

Windows phone internet explorer enlarge text in one td

The problem is, that I have table for content with 3 td's, side td is 200px wide and the middle one width isn't defined, everything seems great on computer browsers (even internet explorer), but when it comes to testing on windows phone browser, in middle td text is much bigger, I'd would say twice as big as it should be and nothing seems to fix that, yes I tried writing font-size value to it in css, but that didn't seem to make any difference.
Sorry that I can't supply a screenshot from my windows phone because of broken power button, I'm using standard windows phone 8.1 internet explorer.
CSS of the table
#content_table {
width: 1024px;
border-spacing: 0;
margin-bottom: 30px;
border-collapse: collapse;
table-layout: fixed;
}
#content_table td:not(:last-child) {
padding: 0 15px 0 0;
}
#content_table #side_content {
width: 200px;
vertical-align:top;
}
#content_table #main_content {
width: 100%;
vertical-align:top;
font-size: 16px;
}
.side_content_title {
background: #c9cbce;
border-top: solid 2px #535f7c;
border-bottom: solid 2px #535f7c;
text-align:center;
width: 200px;
color: #353c4c;
padding: 2px 0;
}
.side_content {
background: rgba(243,243,243,1);
-moz-box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
width: 190px;
padding: 5px;
border-bottom: solid 2px #535f7c;
color: #535f7c;
}
.main_content_title {
background: #c9cbce;
border-top: solid 2px #535f7c;
border-bottom: solid 2px #535f7c;
padding: 2px 0 2px 30px;
color: #353c4c;
}
.main_content {
background: rgba(243,243,243,1);
-moz-box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
padding: 5px;
border-bottom: solid 2px #535f7c;
color: #535f7c;
}
HTML part
<table id="content_table">
<tbody>
<tr>
<td id="side_content">
<div class="side_content_title">title</div>
<div class="side_content"><br/><br/></div>
</td>
<td id="main_content">
<div class="main_content_title">title</div>
<div class="main_content">
Lorem ipsum<br/><br/>
</div>
</td>
<td id="side_content">
<div class="side_content_title">title</div>
<div class="side_content"><br/><br/></div>
</td>
</tr>
</tbody>
</table>
Thanks Mousey for helping, and pointing out to previously answered question. Setting view-port for device width could help if I wouldn't used few fixed position objects, but adding
-ms-text-size-adjust: none;
to body fixed text-size problem without messing up with anything else.
Use belo code in the body tag or to the main table
-ms-text-size-adjust: none;
Removing the line font-size: 16px; from this code should render will all <td> using the same font size
#content_table #main_content {
width: 100%;
vertical-align:top;
}
I think you are finding the phone automatically shrinks the font on smaller devices - except when it is manually specified in the code. 16px will look large on a mobile.
Setting the view-port may also help - see HTML CSS - Font size oversized when shown on windows phone for font-size issues on windows phone
Edit from the link above, using this fixed the problem as EDWcode stated.
-ms-text-size-adjust: none;

CSS border style inside

I want to create a border as shown in the image. I tried with all the styles inset, outset,ridge and groove but I was not able to get the expected result.
Is there any way to bend border towards inside till middle and get back towards till top(hope you understand the problem).
If it's repeated question please add the solution link.
Thanks in advance.
I have tried this:
div {
border-bottom: 1px ridge #B5B9BB;
/*border-bottom: 1px inset #B5B9BB;
border-bottom: 1px outset #B5B9BB;
border-bottom: 1px groove #B5B9BB; */
}
You could use outline:
.bordered {
border-bottom: 1px solid grey;
background: aliceblue;
outline: 5px solid aliceblue;
}
<div class="bordered">Available Apps</div>
Demo
Seems why not just use a border on the text?
div {
background: lightgrey;
padding: 0.5em;
}
p {
border-bottom: 1px ridge #B5B9BB;
}
<div>
<p>Available Apps</p>
</div>
It is probably best to use a wrapping element if possible; it is more flexible than outline (supports border-radius, box-shadows etc.)
For example:
<div class="headline-area">
<h2>Available Apps</h2>
</div>
with the CSS:
.headline-area {
background:#D4D9DC;
padding:5px;
}
.headline-area h2 {
border-bottom:1px solid #B5B9BB;
}
Whenever I am in your situation I use box-shadow:
body {
background:#D1D6D9;
font-family:verdana;
}
div {
border-bottom: 1px solid #B5B9BB;
box-shadow:0 1px 1px rgba(255,255,255,.7);
padding-bottom:5px;
}
<div>Available Apps</div>
You could always try a hr tag. You can then style it in CSS to your desired preference.
HTML
New apps
<hr>
Try this Also but you need an extra Div to do so.
HTML
<div class="outerDiv">
COntent
<div class="innerDiV">
</div>
<div>
CSS
.outerDiv{
background-color: grey;
height: 32px;
text-align: center;
padding: 16px;
font-weight: bolder;
font-size: 25px;
}
.innerDiV{
margin: 0 auto;
border: 1px solid black;
width: 98%;
margin-top: 10px;
}
Demo

Effect of <table> border-collapse: collapse; on the box shadow in IE browsers

i created the table with empty span tags with padding giving them a box shadow.
its simple html structure is as follow.
<table>
<tr>
<td><span class="tokenHolder" data-ans="5" style="padding: 2px 53.5px;"></span></td>
<td><span class="tokenHolder" data-ans="5" style="padding: 2px 53.5px;"></span></td>
</tr>
<tr>
<td><span class="tokenHolder" data-ans="5" style="padding: 2px 53.5px;"></td></span>
<td><span class="tokenHolder" data-ans="5" style="padding: 2px 53.5px;"></span></td>
</tr>
</table>
with css code as below..
th {
font-size: 20px;
background-color: #cccccc;
padding: 5px 8px;
}
td {
padding: 5px 5px 10px 5px;
font-size: 18px;
background-color: #ececec;
}
th,td {
border-right: 2px solid #dedcdd;
}
table {
margin-top: 25px;
border: 2px solid #dedcdd;
position: relative;
border-collapse: collapse;
}
.tokenHolder {
background-color: white;
cursor: pointer;
position: relative;
color: transparent;
background-size: 100% 100%;
background-repeat: no-repeat;
box-shadow: 2px 2px 2px gray;
border-radius: 2px;
}
the respective js fiddle is at http://jsfiddle.net/Pank/4A9BM/
here in after using border-collapse:collapse at the table removes the box shadow for the span inside it..
otherwise hole code is running fine in all browsers..
Please help for this ie related quirk..
Just add
<!doctype html>
in the top of your HTML document. It will work fine. Tested in IE10
updated answer.
screen shot: When i use
http://www.image-share.com/ijpg-2440-42.html
Screen shot: without using
http://www.image-share.com/ijpg-2440-43.html
http://www.image-share.com/ijpg-2440-44.html
here is the link to it. just read it.
w3schools

HTML CSS Box Styling

I am trying to do some CSS to complement my HTML code. I am effectively trying to make a little box which changes size based on the amount of text there is. Currently, this is what it looks like in action.
Essentially, I'd like it to form a little box around the text. Notice the last 'box' in the image, if the string is too long, it cuts it off and continues on the next line.
Included is the CSS code and an example of usage.
<style type="text/css">
boxytest
{
padding: 10px;
text-align: center;
line-height: 400%%;
background-color: #fff;
border: 5px solid #666;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
-webkit-box-shadow: 2px 2px 4px #888;
-moz-box-shadow: 2px 2px 4px #888;
box-shadow: 2px 2px 4px #888;
}
</style>
<body>
<div align="center">
<boxytest> Hey guys! What's up? </boxytest>
</div>
</body>
Any help is greatly appreciated.
As chipcullen says inventing your own element is probably not the best way to go about this. But to answer your question the key style decleration your missing appears to be display:inline-block;
jsfiddle here
Well, I think first off, in terms of markup, you want to make boxytest a class, and not create a new element. And don't use 'align=center'. It's a pain to maintain.
I would do something like this:
<body>
<p class="boxy">Test sentence</p>
<body>
The in CSS:
.boxy {
padding: 10px;
text-align: center;
line-height: 400%%;
background-color: #fff;
border: 5px solid #666;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
-webkit-box-shadow: 2px 2px 4px #888;
-moz-box-shadow: 2px 2px 4px #888;
box-shadow: 2px 2px 4px #888;
/* to prevent word wrapping */
white-space: nowrap;
overflow: hidden;
}
The last bit is based on this post.

How do I disable the shadow only on one edge?

How do I get rid of the shadow in the red area below? I have seen other similar questions but don't know how to apply that here.
Live Demo: http://jsfiddle.net/xFa9M/
CSS:-
#list li{
border: 2px solid black;
border-top-width: 1px;
border-bottom-width: 1px;
padding: 4em;
z-index: 1;
}
#list li .tip{
position: absolute;
left: 200px;
top: 0px;
border: 2px solid black;
border-left-width: 0px;
z-index: 0;
display: none;
}
#list li:hover{
-moz-box-shadow: -5px 5px 5px black;
-webkit-box-shadow: -5px 5px 5px black;
box-shadow: -5px 5px 5px #555;
}
#list li:hover .tip{
-moz-box-shadow: -5px 5px 5px black;
-webkit-box-shadow: -5px 5px 5px black;
box-shadow: -5px 5px 5px #555;
}
Html:-
<ul id="list">
<li class="top">About Me
<div class="tip">Asas</div>
<li>Garage
<li class="bottom">My Blog
</ul>
Please note that it is ok for me to use JS code tricks, if needed.
If I understand correctly, you are having problems with the middle li's having shadow, while you only want the first (and maybe last) li to have shadow.
If I understood correctly, you could use the li:first-child and li:last-child to set the shadow to the first and last element of your list.
But this is not the case. If you want to hide the left shadow on your .tip, you should set the first paramater of box-shadow to 0px. The first parameter is the horizontal offset.
Like here:
http://jsfiddle.net/rf47W/
Was this what you were looking for?
You cannot.
In order to get around the issue, don't assign dropshadows to the "about me" and "asas" boxes separately, but rather wrap them in a single container and apply the shadow to it.
Have you tried targeting that element with a specific class/id/whatever selector and inserting
the code below?
-moz-box-shadow:none;
-webkit-box-shadow: none;
box-shadow: none;
The CSS and HTML given does not produce the display shown in the image, so I'm having to guess, but try wrapping the asas box in another box with bottom padding and hidden overflow.