I've created the following fiddle with a sample table where I need to add specific style to each table header.
fiddle
The following pic shows a sample of the style I need to add. How can I achieve this styling using only the th tag?
sample style
To make arrows use :after filter with css3 triangles.
To make frame inside th use outline.
jsFiddle (Forked from your fiddle and marked with comments what was changed).
Briefly:
/* Makes triangle */
.table-header th:after {
content: " ";
/* just adjusting position */
margin-left: 5px;
margin-right: 3px;
margin-bottom: 4px;
display: inline-block;
/* reference to http://css-tricks.com/snippets/css/css-triangle/ on how to make triangles */
/* triangle */
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #ccc;
/* /triangle */
}
/* Adds outline for active element (<th class="active">) */
.table-header th.active {
outline: 1px solid #ccc;
outline-offset: -9px;
}
/* Forbid header to do word-wrapping, or it will look ugly */
.table-header th {
/* ... some code that was here ... */
white-space: nowrap;
}
You may customize colors, margins and outline to your hearts content.
UPDATED: Edited link to fiddle to third revision.
Related
I have style HTML 5 progress tag. And removed default styles however I am not sure why there is small gap coming in between border and filled area in progress. Please see below screenshot.
Please help me to remove 1px gap between filled dark blue area and red border.
Stackblitz URL: https://stackblitz.com/edit/angular-ivy-qgwxn1?
use height 100% to fill the gap, and border to box-shadow method to completely remove any remaining spaces,
progress[value] {
flex-grow: 1;
margin-right: 0.5rem;
/* Reset the default appearance */
-webkit-appearance: none;
appearance: none;
height: 100%;
border-radius: 5px;
overflow: hidden;
box-shadow: 0 0 0 1px red;
/* border: 1px solid red; */
}
I want to align the checkbox, label and text input in a same line using css. I can do it by using the default template of the browser.
However I really liked the simple theme given in this link. The theme has label and a input text. I wanted to add a checkbox as well at the beginning of the line. Somehow adding a checkbox inside the div makes the arrangement awry.
Though its better to look at the code in the link, I am providing a snapshot here:
HTML
<form>
<div>
<!--NEED TO ADD CHECKBOX HERE -->
<label for="pub_url">Public URL</label>
<input type="text" id="pub_url" name="pub_url" value="http://cssdeck.com">
</div>
</form>
CSS3
/* Onto the styling now. Some quick generic styles first. */
html, body {
width: 100%; height: 100%;
}
body {
font-size: 76%;
font-family: Verdana;
background: #eee;
padding: 50px 0;
}
form {
background: #fafafa;
padding: 20px;
width: 400px;
margin: 0 auto;
border: 1px solid #ffe2e3;
}
form div {
/* Float containment */
overflow: hidden;
}
/* Things are looking good now, onto the main input field
styling now! */
/*
Lets change the box model to make the label and input
contain into the 100% div.
You might want to specify the box sizing properties inside
`* {}` at the top.
Things are looking great now! Lets just spice it up a bit.
*/
form label, form input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
form label {
font-weight: bold;
background: linear-gradient(#f1f1f1, #e2e2e2);
padding: 5px 10px;
color: #444;
border: 1px solid #d4d4d4;
/* lets remove the right border */
border-right: 0;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
line-height: 1.5em;
width: 30%;
/* takes the width properly now and also the
spacing between the label and input field got removed. */
float: left;
text-align: center;
cursor: pointer;
}
/* The label is looking good now. Onto the input field! */
/*
Everything is broken now! But we can fix it. Lets see how.
*/
form input {
width: 70%;
padding: 5px;
border: 1px solid #d4d4d4;
border-bottom-right-radius: 5px;
border-top-right-radius: 4px;
line-height: 1.5em;
float: right;
/* some box shadow sauce :D */
box-shadow: inset 0px 2px 2px #ececec;
}
form input:focus {
/* No outline on focus */
outline: 0;
/* a darker border ? */
border: 1px solid #bbb;
}
/* Super! */
p.s: It will be delightful if someone can stylize the checkbox in the same way as the example
try this one,
form input[type="checkbox"] {
width:20px;
}
<div>
<input type="checkbox" >
<label for="pub_url">Public URL</label>
<input type="text" id="pub_url" name="pub_url" value="http://cssdeck.com">
</div>
http://jsfiddle.net/KW6AY/1/
Here you go \w quick styling:
http://codepen.io/daniesy/pen/puema
alter the css to input[type="text"] and lower the width to around 60% (so it won't affect your checkbox), add a checkbox with a float left
just rename class
form input into form input[type="text"]
Good luck.
I want to make a table via Html/Css (Javascript if needed) which basically looks like this:
As you can see there every row in this table has a bottom border, which starts above an image in the table, and then goes down to the other columns.
Is there any way to do this? (Maybe with a transparent image?)
You can use a psudo element with a rotation to solve this:
Check out this jsfiddle
http://jsfiddle.net/zRMLr/
You will likely have to play with the numbers a lot to get it to work with whatever you want.
what I used in this demo (no images) BUT only works for IE9+
html:
<table>
<tr><td><div></div></td><td></td><td>Some sort of text</td></tr>
<tr><td><div></div></td><td></td><td>Some sort of text</td></tr>
<tr><td><div></div></td><td></td><td>Some sort of text</td></tr>
</table>
css:
table {
width: 400px;
}
td:first-child {
border-top: 1px solid black;
width: 20px;
}
td:first-child:after {
content: '';
border-top: 1px solid black;
display: block;
width: 28px;
height: 1px;
float: left;
position:relative;
top: -5px;
left: 24px;
transform:rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
}
td:first-child div {
width: 10px;
height: 10px;
background-color: red;
}
td:nth-child(2) {
width: 14px;
}
td:last-child {
border-bottom: 1px solid black;
}
What you may do to achieve the desired effect is:
Create a div with a left/right border
Rotate using CSS3 rules the div to give this effect
Or
create a div with a left/right border
use border radius to have the desired effect
I hope this helps, if you would like I can bring some sample of code for you
I have borders already set up with CSS for the .message class.
However I would like to make it so only the top border is visible with an inline style. Can someone tell me how I can do this.
You can set all the borders up using the shorthand notation, but then override the one border you want to present differently, for example:
.message {
border: 2px solid #f90;
border-top: 2px solid transparent;
}
Or, for brevity, you can simply override one property of that border (color, width or style):
.message {
border: 2px solid #f90;
border-top-width: 0; /* or whatever */
border-top-style: none; /* or whatever */
border-top-color: transparent; /* again, or whatever... */
}
If you use shorthand, you must set all of the widths, so you won't be able to use the width applied from the .message class.
.test { border-width: 1px 0 0 0 } /* top right bottom left */
I want to make something like a horizontal line with a text in the middle of it. It should look like this (text image follows):
------------------------------------------ TEXT --------------------------------------------
the line should be dotted and the text in the middle should separate the line in half.
I came up with the idea of using a table with 3 elements with percentage values in width attribute but maybe there is a better solution.
I hope it's clear. Thanks for ideas
<div id="line"><span>TEXT</span></div>
And CSS:
#line{
border-bottom: 1px black dotted;
overflow:visible;
height:9px;
text-align:center;
margin: 5px 0 10px 0;
}
#line span{
background-color: white;
text-align:center;
padding: 0 5px;
}
See Example on JSFiddle
I would use CSS, and two containers:
Demo: http://jsfiddle.net/LRSuJ/
HTML:
<div class="something">
<div class="content">Text</div>
</div>
CSS:
.something {
border-bottom: dotted 1px #000;/* Border style */
height: 10px; /* Adjusted height */
margin-bottom: 10px; /* Proper offset for next element */
line-height: 20px; /* Actual text height */
text-align: center; /* Center text */
}
.content {
background-color: #FFF; /* Hide previous dots */
display: inline; /* Inline element */
padding: 0 10px; /* Customisable left/right whitespace */
}
You could use a fieldset and legend:
<fieldset>
<legend>TEXT</legend>
</fieldset>
fieldset
{
border-top:solid 1px black;
}
fieldset legend
{
text-align:center;
}
http://jsfiddle.net/2amBc/
I would do it like this:
HTML
<fieldset>
<legend>Text with dotted line</legend>
</fieldset>
CSS
fieldset {
border: 0;
border-top: 1px dotted gray;
}
legend {
text-align: center;
}
jsFiddle demo: http://jsfiddle.net/XZcRB/