How to put a line on top of text in html? - html

So I want to try to do this in html and css but I can't seem to find anything. I only way I can think is by importing the text as an image but that will look bad. P.S Light blue line is for centering as I am designing the site in Photoshop first
<p class="test">
Conact Me
</p>
.test {
border-top-style: solid;
border-bottom-style: solid;
border-bottom-width: 1px;
}

A simple solution is using text-decoration: underline overline;.
p {
text-decoration: overline underline;
}
<p>
CONTACT ME
</p>

You can use border-top in css to create a line above text.
.mytextbox {
border-top: 1px solid #ff0000;
}
border-top property
Example of use

Try using borders to achieve the look you are wanting:
a.my-class {
display: inline-block;
padding: 5px 15px;
border-top: 2px solid #000;
border-bottom: 2px solid #000;
line-height: 1em;
text-decoration: none;
}

Well, you'd want to have the text element within a div, set the bg color property of the div to the color you're going for, and then set margins for the text element to push off the text by ~10px or so (looks like that's about where it's at in your mock up). From there you can set a border to only top, and bottom and style accordingly.

You can put the text inside a block level element and apply a top and bottom border. Advantage of this method against the text-decoration: underline overline; is, that you can simply define the space between text and lines with padding as you need it.
To make the width as long as the text is, just use display: inline-block;.
body {
background: #5cc8f6;
}
div {
display: inline-block;
padding: .5em;
border-top: 1px solid white;
border-bottom: 1px solid white;
color: white;
text-transform: uppercase;
font-family: Verdana;
font-size: 2em;
}
<div>Contact me</div>

Related

How to underline a text (with full width) using CSS

I've this html code:
<a class="jstree-anchor jstree-disabled textualstatements-jstreenode-parent" href="#" tabindex="-1" id="td72383_anchor"><i class="jstree-icon jstree-themeicon fa fa-folder jstree-themeicon-custom" role="presentation"></i>My example text</a>
And this CSS:
.textualstatements-jstreenode-parent {
text-decoration: underline !important;
text-decoration-color: #2eaaa1 !important;
text-decoration-thickness: 2.5px !important;
text-underline-offset: 2px !important;
font-weight: bold;
width: 100%;
}
And this is rendered like:
However, I want the green line to be expanded using the full width from the block, can this be done using text-decoration?
Instead of underline, create bottom border,
border-bottom:1px solid #000;
Use border.
p{
border-bottom: 2px solid black;
}
Put it in a div and set the bottom-line to green.
div {width: 100%; border-bottom: 1px solid #2eaaa1;}
Or if you perse want to underline, you can expand the a text with spaces: a lot of & nbsp;.
This solution works for me.
Here is an explanation already on stackoverflow CSS Styling text areas like notebook-look
.textualstatements-jstreenode-parent {
font-weight: bold;
width: 100%;
border-bottom: solid #2eaaa1 2.5px;
display: inline-block;
}
<a class="jstree-anchor jstree-disabled textualstatements-jstreenode-parent" href="#" tabindex="-1" id="td72383_anchor"><i class="jstree-icon jstree-themeicon fa fa-folder jstree-themeicon-custom" role="presentation"></i>My example text</a>
You are trying to make width 100% for an anchor tag which is an inline element.
width:100% will not have any effect unless the element is block or inline-block.
Try this
.textualstatements-jstreenode-parent {
text-decoration: underline !important;
text-decoration-color: #2eaaa1 !important;
text-decoration-thickness: 2.5px !important;
text-underline-offset: 2px !important;
font-weight: bold;
width: 100%;
display: block;
}

Different border bottom for links with bold text

On this page (http://nate.fm/testing/) you can see that the text link's bottom border gets pushed down. Can anyone tell me where I can change that in the CSS?
You can set the <a> tag to display: inline-block; then reduce the line-height.
Something like this maybe:
.post-content a {
line-height: 15px;
display: inline-block;
}
.post-content a {
/* border-bottom: 3px solid #eee; */
text-decoration: underline;
}
They are using border-bottom along with line-height, the line-height property causes the effect of "pushing" down the border you are mentioning
.post-content a {
border-bottom: 3px solid #eee;
line-height: 160%;
}

What is causing uneven spacing between these buttons of mine?

I can't figure out what is causing the uneven spacing that you see in the image http://i.imgur.com/AZoXzYf.png (can't embed images yet ... sorry)
which comes from http://playclassicsnake.com/Scores. My relevant CSS is
.page-btn { background: #19FF19; color: #FFF; border: 0; border: 3px solid transparent; }
.page-btn.cur-page { border-color: #FFF; cursor: pointer; }
.page-btn + .page-btn { margin-left: 5px; }
and I've inspected the elements to make sure there's nothing fishy. What's the deal?
You have a new line character in your HTML just after your first button:
<button class="page-btn cur-page">1</button>
<button class="page-btn">2</button><button class="page-btn">3</button>
Make it all in 1 line and it will start to work without any extra spaces:
<button class="page-btn cur-page">1</button><button class="page-btn">2</button><button class="page-btn">3</button>
Your CSS is perfectly fine and doesn't need to be altered as mentioned by others..
Hi now try to this css
#page-btns-holder {
width: 80%;
margin-top: 12px;
font-size: 0;
}
div#page-btns-holder * {
font-size: 14px;
}
.page-btn {
background: #19FF19;
color: #FFF;
border: 0;
border: 3px solid transparent;
display: inline-block;
vertical-align: top;
font-size: 14px;
}
Define your btn display inline-block and remove space to inline-block element define your patent font-size:0; and child define font-size:14px; as like this i give you example
Remove Whitespace Between Inline-Block Elements
Try to make the font-size of the parent content 0, also try setting letter-spacing to 0.

CSS border in hover state

Essentially i have a pricing table with the class of .priceblock, and i have a border-bottom on my <li> tags, i simply want it to change color when i hover on the priceblock. The code to me seems correct but nothing changes.
Heres the initial li tag:
ul.pricingtable .priceblock .contents li {
font-family: 'OpenSans';
font-size: 13px;
width: 81.904762%;
height: 35px;
margin:0 auto;
padding: 10px 0;
border-bottom: 1px solid rgba(221,221,221,1);
}
And here hover state css code, this hover class works for he coloring of texts, but i can't change the border color.
.priceblock:hover .contents li {
border-color: rgba(255,117,109,1);
}
Any ideas?
I think you might need to change the hover state from.
.priceblock:hover .contents li {
border-color: rgba(255,117,109,1);
}
To:
.contents li:hover {
border-bottom: 1px solid rgba(255,117,109,1);
}
HTML may be able to read it better.
The css attributes need to be equals.
for example:
If in the first style block you write "ul.pricingtable" then you need to do that in the second block two.
And in the content of block, they need to be same.
for example:
border-bottom: 1px solid rgba(221,221,221,1);
and
border-bottom: 1px solid rgba(255,117,109,1);
You cann'ot use once with "border-bottom" and then with "border-color" only...

How to make entire group change color on hover?

If you go to http://cascade2.hostei.com/collection.html
And hover over the picture of the chandelier, you will notice the entire group turns from a grey to a blue.
But if you hover over the caption below it, you will notice only the caption turns blue.
How can I change it so when I hover over the caption, it will also turn the border of the picture blue?
Preferably in HTML or CSS.
Ignore the shadow and all of the other errors.
HTML:
<center>
<figure class=cheese>
<a class=cheese href="images/cascadelucecatalog.pdf">
<center><img src="images/cataloguefront.jpg" width="400" height="398" alt=""/>
</center><figcaption>
<h2><p>2013 Cascade Luce Catalog</p></h2></figcaption></a>
</figure></center>
CSS:
.cheese {
background-color: #4D4D4D;
-webkit-box-shadow: 1px 1px 15px #999999;
box-shadow: 1px 1px 15px #999999;
color: #FFF;
}
.cheese p{
color: #FFF;
}
.cheese:hover, .cheese:active, .cheese:focus, .cheese :hover, .cheese :active, .cheese :focus{
text-decoration: none;
background-color: #43A6CB;
}
You need to target the img when .cheese is hovered.
.cheese:hover img {
background-color: #43A6CB;
}
Take the padding off your image. It's obscuring the background. Apply padding to the parent element if needed.
You're setting the background color of the image to white
figure img {
padding: 10px;
background-color: #FFFFFF;
-webkit-box-shadow: 1px 1px 15px #999999;
box-shadow: 1px 1px 15px #999999;
}
Just remove the background-color: #FFFFFF; property and everything should work fine.
It looks quite better white a grey border to see where the image ends in my opinion too.
Try this, targeting the img on hover
.cheese a img:hover {
background: blue;
}
FIDDLE