At the moment, I have page headings which I want to style like this:
<div class="page_header">Categories</div>
My style looks like this:
.page_header {
font-family: markerfelt-thin-webfont;
text-shadow: 1px 1px 2px #000000;
font-size: x-large;
color: #bbbb75;
padding-bottom: 10px;
}
But I have been asked to add a small image to the left of the text.
So, I could go an edit every page header:
<div class="page_header"><img src="http://www.clker.com/cliparts/W/e/S/a/V/m/push-pin-th.png" />Categories</div>
But I was hoping I could edit the CSS to accomplish this for me. Is there a way I can add an image to the CSS, left of the text (With a (missing) gap between the image and the text)?
I have attempted the ::before in the css (New to me, so I am doing something wrong), like this:
.page_header {
font-family: markerfelt-thin-webfont;
text-shadow: 1px 1px 2px #000000;
font-size: x-large;
color: #bbbb75;
padding-bottom: 10px;
}
.page_header::before{
content: url('~/images/pushpin.png');
}
But all that happens is I get a huge gap before the heading. But if I use http:// to reference the image, it works. Using ~\images\myimage.png fails.
you try with code below maybe can help you:
.page_header {
font-family: markerfelt-thin-webfont;
text-shadow: 1px 1px 2px #000000;
font-size: x-large;
color: #bbbb75;
padding-bottom: 10px;
position:relative;
padding: 30px 0 0 120px;
}
.page_header::before{
position:absolute;
left:0;
top:0;
content:url('http://www.clker.com/cliparts/W/e/S/a/V/m/push-pin-th.png');
}
Working Demo
Here's how you can style all headers with the same image:
.page_header {
background: url('http://www.healthylivingjunkie.com/wp-content/uploads/2014/10/bulletPoints.png') left center no-repeat;
background-size: 14px;
font-family: markerfelt-thin-webfont;
text-shadow: 1px 1px 2px #000000;
font-size: x-large;
color: #bbbb75;
margin-bottom: 10px;
padding-left: 20px;
}
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
There's a few ways to achieve this. Either by use of the :before selector or by setting the background of the div to your image and pushing the text across using padding.
You could set the background image of the div and pad the left side to move the text over
padding-left:120px; // width of image + spacing
background: url("http://www.clker.com/cliparts/W/e/S/a/V/m/push-pin-th.png") no-repeat;
Yeah, you don't have to go to code part and you can do this with css using pseudo element before as you have to insert it before the element.
.page_header:before{
content:url('http://www.clker.com/cliparts/W/e/S/a/V/m/push-pin-th.png');
}
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
<div class="page_header">Categories</div>
Related
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>
I want the red border to be tight around the blue text (e.g. no whitespace). What is causing the whitespace and how do I remove it?
#propertyDetails .display_address {
font-size: 1.75rem;
font-weight: bold;
color: #3498db;
margin:0px;
padding:0px;
border: 1px solid red;
}
<div id="propertyDetails">
<div class="display_address">Test Address</div>
</div>
Try line-height:16px; if that's not compatible with your screen, adjust the pixels.
The line-height is what is causing it. Make it equal to 1, which is relatively 100% of the font-size so that in the event of different font-size, you don't need to change the line-height again.
#propertyDetails .display_address {
font-size: 1.75rem;
font-weight: bold;
line-height: 1;
color: #3498db;
margin:0px;
padding:0px;
border: 1px solid red;
}
<div id="propertyDetails">
<div class="display_address">Test Address</div>
</div>
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.
this is my html
<div class="logoArea">
<img src="images/oifcoman-logo.jpg"/>
<div class="titleClass">Call Center Dashboard</div>
</div>
this is my css
.logoArea {
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
}
.titleClass {
color: #343434;
font-weight: normal;
font-family: 'Ultra', sans-serif;
font-size: 36px;
line-height: 42px;
text-transform: uppercase;
text-shadow: 0 2px white, 0 3px #777;
margin:auto;
background-color:red;
width:40%;
top:10px;
}
This is what the result:
I want it to be this:
Set the image float:left; and the text display:inline-block; and the .logoArea text-align:center;.
Working fiddle
There are few ways to solve this. Here is one with minimal changes to your existing styling.
.logoArea img {
float: left;
}
Usually it requires additional changes in the code for actual centering in the parent window, but it seems to go well with the other styles you already have.
EDIT
Looking again at the result, I'm having second thoughts. My solution is good only for non-dynamic elements (elements that won't change dynamically but remain the same). Since it appears to be a header and therefore a relatively static element, my solution may still be valid, only with adding a required amount of padding-top to the center div. I don't know how much because in your example you used a very large font-size and I have no idea of the size of the image.
You can use CSS vertical-align:middle if the element is td (not div) or try this trick: http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/
Try using:
<div class="logoArea" style="display:table-cell; vertical-align:middle">
<img src="images/oifcoman-logo.jpg"/>
<div class="titleClass">Call Center Dashboard</div>
</div>
Try this:
HTML:
<div class="logoArea">
<img src="http://i.stack.imgur.com/O3d6S.jpg?s=128&g=1"/>
<div class="titleClass">Call Center Dashboard</div>
<div style='clear:both;'></div> </div>
CSS:
.logoArea {
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
}
.logoArea img {display:block;width:100px;height:100px;float:left;}
.logoArea .titleClass {float:left;}
JavaScript (must include jQuery first)
$(document).ready(function(){
var h=$('.logoArea').height();var ch=$('.logoArea .titleClass').height();
var pTop=((h-ch)/2)+'px';
$('.logoArea .titleClass').css('paddingTop',pTop);
});
Demo: http://jsfiddle.net/zcAjq/
I want to wrap an <a> around a div. When I add that, the border's colour remains the same orange the text is colored.
The orange turns to black when I toggle color rule in Chrome's developer tools, however I obviously don't want the viewer to be required to do the same.
Notice that only the Block Fuse project box has this issue, none of the other boxes do because they do not have an <a> tag.
I have reproduced this issue in:
Chrome Version 23.0.1271.95
Chrome Canary Version 25.0.1342.0
Here is the relavent html:
<a href="projects/blockfuse.html">
<div class="project">
<div class="projectTitle">Block Fuse</div>
<div class="projectDescription">Block Fuse is a game about knocking as many blocks onto the floor as possible.
<div class="projectImage"><img class="projectImage" src="images/BlockFuse.png"></img></div>
</div>
</div>
</a>
Here is the relavant css:
div.projectTitle {
text-align: center;
font-size: 20pt;
color: #F90;
padding: 20px 0px 15px 0px;
font-family: "Arial", "Helvetica", Sans-Serif;
border-radius: 20px 20px 0px 0px;
border-style: solid;
border-width: 0px 0px 1px 0px;
border-color: black;
background-color: #444;
}
div.projectDescription {
height: 310px;
font-family: "Arial", "Helvetica", Sans-Serif;
font-size: 12pt;
color: #EEE;
text-shadow: 1px 1px 1px #000;
background-color: #777;
padding: 17px;
border-radius: 0px 0px 20px 20px;
}
Try it live on my website: http://www.rollingkinetics.com/index.html
I think the issue here is that you need to set the color for the a:visited selector. I did not see the issue initially, but i did after I clicked on the link.
I recommend to place the hyperlink inside the div. This makes a better behavior as I experienced.
(in this case the link will be applied for the children of the div and the outer wont get additional a:link color)
make text decoration none on hyper link just add this
a{
text-decoration:none;}