May i know how to add space / padding-bottom after border-bottom? Sample shown as below. I dont wish add some objects or make it, just wish to use "h2" only. For example:
< h2>h2 header< /h2>
< p>Next element< /p>
DEMO
h1 {
margin-bottom:50px; /* space from border to next element */
padding-bottom:10px; /* space from element to border */
border-bottom:1px solid #aaa;
}
CSS box model - Reference
You can use margin-bottom: in your css. Like in the code below and in the demo. I have used 50px as an example.
h2 {border-bottom:1px solid grey; margin-bottom:50px;}
DEMO
Related
I'm creating my site based on bootstrap But wanna do some customization.
Any idea to overwrite the bootstrap default style with this one
I know to replace the box style to underline only can use this
border: 0;
outline: 0;
But not knowing how to bend the line
I looked up the relevant Bootstrap 3.3.7 (most recent non-alpha) code for you, which would be the .form-control class.
If you override that class with the following CSS you will likely achieve the effect you are looking for.
.form-control {
border: 0; /* to hide border initially */
border-bottom: 1px solid #ccc; /* to set the bottom border (the only one we need) */
border-radius: 8px; /* to round borders or 'bend the line' */
}
Thus, border-radius is the CSS property you are looking for.
I want to create horizontal line as shown in below image using css. but unable to create so, i have never seen such line before using css.
Can anyone who are export in css can help me with this?
I know basic like this
Update
Note: Actually, i have to put this in my email template, so i am avoiding images. Just pure css
The only CSS I can think of, is a stretched (transformed) dotted border:
div {
border-bottom: 1px dotted black;
transform: scale(1,10);
}
<div></div>
If it's for an email (see comments section):
use <img src="bars_300x10.png" style="display:block; width:300px; height:10px;">
with an image exactly cut as the expected email design.
Using simply a 3x1 px background base64 .gif:
hr{
border:0;
background: url('data:image/gif;base64,R0lGODlhAwABAIAAAAAAAP///yH5BAAAAAAALAAAAAADAAEAAAICRFIAOw==');
height:10px;
}
<hr>
One posibility that gives you absolute control about the results is a gradient
div {
width: 300px;
height: 40px;
background: linear-gradient(to right, black 0px, black 5px, white 5px, white 30px);
background-size: 30px 100%;
}
fiddle
You can adjust the size of the pattern, the width of the black strip, the color ...
I commented but, seems like it would work to use vertical pipes (|) and then to control their size/color/spacing using css font techniques. I'll post some examples. It's not clear to me if using pure css is a requirement for you or not.
span {display:block;}
.a { color:blue; font-size:2em; letter-spacing:.2em; }
.b { color:red; font-size:1em; letter-spacing:2px; }
.c { color:green; font-size:8px; letter-spacing:1px; }
<span class="a">||||||||||||||||||||||||||||||||||||||||||||||||||||||||||</span>
<span class="b">||||||||||||||||||||||||||||||||||||||||||||||||||||||||||</span>
<span class="c">||||||||||||||||||||||||||||||||||||||||||||||||||||||||||</span>
Another option, if you don't need much variance in the appearance would be to create a single bar "image", then set it as the background-image of a <div/>, and finally apply repeat-x on it.
Styled my checkboxes like buttons as suggested here in this article:
CSS: styled a checkbox to look like a button, is there a hover?
Now I've been trying to add some margin to the buttons. This won't work, as soon as the button is selected, only the area without margin is highlighted. This looks awfull...
#ck-button label span {
text-align:center;
padding:3px 0px;
display:block;
margin: 10px;
}
See here: http://jsfiddle.net/Vq759/
Anyone know how to solve this?
Thanks mates :)
I think you're overcomplicating things with your HTML/CSS, here's a quick re-do with how I'd style a checkbox (which is completely customizable to suit anything you need).
Simple HTML:
<input type="checkbox" value="1">
<label>Red</label>
I start styling the checkbox by simply hiding it:
input[type="checkbox"] {
display: none;
}
This leaves optional events/states like :checked intact.
From here I style the entire object to suit my needs, for example:
input[type="checkbox"] + label {
display:inline-block; /* or block */
line-height:normal;
cursor:pointer;
padding: 3px 14px;
background-color: #EFEFEF;
border-radius: 4px;
border: 1px solid #D0D0D0;
margin: 40px 100px 10px 40px; /* however you please */
}
/* hover event */
input[type="checkbox"] + label:hover {
border-color: #000;
background-color: #911;
color: #fff;
}
/* checked checkbox */
input[type="checkbox"]:checked + label {
border-color: #000;
background-color: #888;
color: #fff;
}
Margin works flawlessly.
Fiddle: http://jsfiddle.net/8e5Xa/
If you are trying to make the button essentially bigger and still make the whole thing highlight onClick, use padding instead of margin:
#ck-button label span
{
padding: 10px;
}
Margin puts white-space around an element. Padding puts white-space within an element.
JSFiddle
The + operator in this selector:
#ck-button input:checked + span
.. does not function properly in older browsers. It sort of works, but has bugs when doing the kind of thing you're trying to do here (in particular, changing the :checked state of the adjacent element). Sorry, but what you're trying to do is impossible if you want all browsers to be supported.
You will need to use JavaScript if you want the text colour of the span to change when selected in all browsers.
Alternatively, you could pick a colour scheme where it looks OK if the span doesn't change colour, but do change the colour in browsers that support it.
If it changing the margin of the button, do this:
#ck-button {
margin:40px;
background-color:#EFEFEF;
border-radius:4px;
border:1px solid #D0D0D0;
overflow:auto;
float:left;
}
Also have a look at this:
This is the box-model for every HTML element
I am highlighting a div using ui-state-highlight on mouseover and also indenting it on mouse click event. The div is highlighted perfectly when it is not indented but once it is indented highlight still is according to the div's previous position. The highlighted/indented div is a Sortable element. I understand this has probably something do with the CSS but am a noob at that!
Code;
<style>
.ui-state-highlight {border: 4px solid #ffffa1;}
.indent { margin: 0; padding-left: 10px; }
</style>
On Mouse Click;
if ($('#'+(parseInt(pushpin._text))).prop('class') == "indent ui-state-highlight" || $('#'+(parseInt(pushpin._text))).prop('class') == "ui-state-highlight indent"){
$('#'+(parseInt(pushpin._text))).removeClass("indent");
}
else{
$('#'+(parseInt(pushpin._text))).addClass("indent");
}
On Mouseover
$('#'+(parseInt(pushpin._text))).addClass("ui-state-highlight")
Try with margin-left instead of padding-left.
Padding is the space between the content and the border of the element. What you want is to "move" the element to the right.
Just change the CSS to:
.ui-state-highlight, .ui-state-highlight.indent {border: 4px solid #ffffa1;}
.indent { margin: 0; padding-left: 10px; }
Should be a specificity issue.
See Wikipedia http://en.wikipedia.org/wiki/Css
If you look at the heading, it says "Cascading Style Sheets", then it has an underline.
How do you do that?
.heading1 {
/* heading with underline */
}
Use borders:
.heading1 {
border-bottom: 1px solid #aaa;
}
And if you're using Firefox, get Firebug which allows you to inspect any element's CSS attributes so you don't have to guess how a certain style is implemented.
just add in the css: text-decoration: underline;
h1 {
border-bottom: 1px solid gray;
}
If the div is 100% wide the you can put a bottom border
.heading1 {
border-bottom: 1px solid #000;
width:100%;
}
As everyone said get firebug, you can also use google chrome's integrated inspector(which is like firebug).
The border is the wrong (amateur) way to do it. Better use the "hr" tag. It makes an underline a width of the parent div. Put it after the text or heading you want to be underlined. Live example:
Cascading Style Sheets
The code would look like this (oversimplified, of course):
<html>
<head>
<title>Underline</title>
</head>
<body>
<p>Hello</p><hr>
</body>
</html>
Hope this helps!