Using letter-spacing seems to really screw with text-align: http://jsfiddle.net/NFAzv/
Googling hasn't turned anything up. Am I missing something here?
EDIT #1: Here's what I'm getting (Firefox 3.6.8 and Chrome 12.0.742.91 on Vista): link removed due to link limits for newbies (it can be found in the comments) (notice how the centers do not line up at all)
EDIT #2: Here's IE9, with a centered vertical line to show what's wrong: http://i.stack.imgur.com/C0J0n.png
EDIT #3: I have a confirmation in the comments below that the problem shows up for Chrome 10 on Windows 7. At least I'm not the only one going crazy.
It seems that all the browser have converged on a letter-spacing implementation that is plainly at odds with what css3 says should happen.
In particular see Example XV at http://dev.w3.org/csswg/css3-text/#letter-spacing0
Browsers simply don't do this. IE has even changed its behaviour recently (IE9, I think) to be more like the other browsers, and less like the CSS3 spec as it's currently written.
The CSS3 spec in question is still at working draft status, so presumably at some point it will be changed to match what the browsers do.
You may be able to rebalance the lines by adding a padding-left value to match the letter-spacing but that may not always be possible.
Since the problem isn't really described I assume that the text isn't centered perfectly..
You can use text-indent at half the size of the letter spacing to correct this..
.centered {
letter-spacing:12px;
text-indent:6px;
}
Only tested on Chrome OSX though..
It seems to work, but your requirement for this pixel perfectness does not comply with the default working of letter-spacing. If you highlight the text, you will see that it does center.
You could use the following workaround: demo fiddle
<div style="text-align: center;">
<div style="font-size: 130%; letter-spacing: 0.6em; padding-left: 0.6em;">THIS</div>
<div style="font-size: 350%; letter-spacing: 0.4em; padding-left: 0.4em;">ILLUSTRATES</div>
<div style="font-size: 130%; letter-spacing: 0.4em; padding-left: 0.4em;">THE</div>
<div style="font-size: 200%; letter-spacing: 0.1em; padding-left: 0.1em;">PROBLEM</div>
</div>
I have seen similar problem with links underline:last letter's width includes the letter-spacing value.
So apply letter-spacing:0; for the last letters should resolve the issue.
It's ugly but it works
...
<div style="font-size: 350%; letter-spacing: 0.4em;">
ILLUSTRATE<span style="letter-spacing:0;">S</span>
</div>
...
add 50% of the font size as text indent like this
<div style="text-align: center;">
<div style="font-size: 130%; letter-spacing: 0.6em;text-indent:0.3em">THIS</div>
<div style="font-size: 350%; letter-spacing: 0.4em;text-indent:0.2em">ILLUSTRATES</div>
<div style="font-size: 130%; letter-spacing: 0.4em;text-indent:0.2em">THE</div>
<div style="font-size: 200%; letter-spacing: 0.1em;text-indent:0.05em">PROBLEM</div>
</div>
Although this wasn't the exact question here, I had an issue that the starting left point of the text was too far to the right:
I had an issue that my text wasn't centered horisontally any longer after letter-spacing was applied but it was due to that I had restricted the texts container in width, so it was overflowing it's container.. worth to look into.. it may seem stupid but it's an easy misstake actually.
I may be late to this, but just in case my solution helps anyone.
This is an example simple button set up:
<button>Enter</button>
In my stylesheet:
button {
color: #f5ebe0;
border-color: #f5ebe0;
background-color: #00000000;
text-indent: 2rem;
width: 33%;
}
a {
color: inherit;
text-decoration: none;
letter-spacing: 2rem;
}
It seems that letter-spacing does indeed only add spacing either to the right, or only in between the letters. This being the case, (when using letter-spacing) I recommend using an anchor tag with in the button and applying your letter-spacing amount to the text inside the anchor, and then apply the SAME amount of text-indent inside your button.
Related
I am a complete newb with coding, and I'm running into a bit of trouble with some text on my website. The code I am using is as follows:
<p><div style="font-family:blog_script"><font size="7">Hi, We're <b>The Distance</b><p></p></font></p>
</a>
</div><p>
I would really appreciate any help with:
The spacing in between each line (I would like for the lines to be slightly further apart)
There is also a lot of empty space below the text creating a large gap between the HTML code and the normal text on the site, I would like to get rid of this.
See our website for a demo link.
I'd really appreciate any tips you can give me.
Thanks so much for your time.
<div style="font-family: blog_script; line-height: 1;">
<font size="7">Hi there, We're
<b>The Distance</b>
</font>
</div>
I have set line-height for the div. Try this. It worked for me.
You need to edit the associated style sheet for this. For a quick fix for problem 1, you can try putting new line between the lines -
Blockquote
"Hi, We're The < br> Distance"
Blockquote
You need to make a custom css class to manage any adjustments you need to do to a certain HTML element.
.more-height {
line-height: 1;
}
Add the class name to the class="... property of the "we are the distance" like this:
<div style="font-family: blog_script;" class="more-height">
This will make the distance between the lines a bit higher.
You can also inject the style of the div element above with the "line-height" property like this:
<div style="font-family: blog_script; line-height: 1;">
Let me know if this works.
See you could use line-height for reduce spacing. Like one I found on you site. Similarly as below you have to target parent element with different class and id and set his line-height accordingly.
#siteWrapper {
font-family: "Kameron",Georgia,serif;
font-weight: 400;
letter-spacing: 0px;
font-family: "Open Sans";
font-size: 16px;
line-height: 1.5em; /*Line height reduce this and adjust*/
letter-spacing: .4px;
font-weight: 300;
font-style: normal;
color: rgba(0,0,0,.5);
}
Check this simple example which helps you to understand how line-height and letter-spacing works jsFiddle
I've searched the forums but the only answers I'm getting cover issues about the font looking bold or having jaggedy edges.
My h1 #font-face font is displaying at the BOTTOM of my page in Chrome and Safari as of today. I have no idea why. It was fine before.
A good page example to look at is https://www.beatnikbreaks.com/about-us/ - have a look in Chrome and then in Firefox. Firefox displays it at the top as it should be.
Chrome loads it at the top first, then it suddenly jumps to the bottom.
My CSS for the font is:
#pagecontent h1{
margin-top: 0px;
color: #b9b9b9;
font-family: 'lucky_typewriterregular',Times,serif;
font-size: 40px;
font-weight: normal;
line-height: 44px;
letter-spacing: 1px;
margin-left: 0px;
float: left;
text-align: left;
width: 1000px;
}
The HTML is:
<div id="pagecontent">
<p></p>
<h1>About Beatnik Breaks</h1>
<h2>About Beatnik Breaks - Large luxury holiday short term rental in Brighton, ideal for holiday letting and stag & hen party accommodation</h2>
<p></p>
<p>We're a little bit shy... some details about us will follow. Or if there's something specific you want to know, then give us a call or <a class="highlight" href="contact-us">email us</a>...
</p>
<p></p>
</div>
I did update my Wordpress very recently, but I can't see why this would have suddenly done this.
Any help would be hugely appreciated
Thanks in advance
I think can be a problem realted to float, try to add float at pagecontent (the actual container of h1)
#pagecontent{
float:left;
}
I am having a very difficult time getting rid of this persistent 5px whitespace on my website eternalminerals.com
I highlighted it in this screenshot: http://s15.postimg.org/de4sjvqob/5pxwhitespace.png
In google chrome, if I edit the element to have a margin-top: -5px, it gets rid of the whitespace, but since I am using Avada shortcodes, I cannot attach this style to it since it is a shortcode:
<p style="text-align: center; margin-top: -10px; font-size: 19px !important; line-height: 42px !important; color: #FFE396!important; font-family: 'MuseoSlab500Regular', Arial, Helvetica, Sans-Serif;"><strong>That's my opinion. I am Dr George Lundberg, at large at The Eternal Minerals of Life.</strong></p>
</div>
[/raw]
[fullwidth backgroundcolor="#140100" backgroundimage="" backgroundrepeat="no-repeat" backgroundposition="top left" backgroundattachment="fixed" bordersize="0px" bordercolor="#e5e4e4" paddingTop="-5px" paddingBottom="0px"]
<br>
[ajax_load_more post_type="testimonials-widget" posts_per_page="5" pause="true" transition="fade" button_label="Click to show testimonials from real physicians"]
[/fullwidth]
As you can see, paddingTop="-5px" doesn't cut it. Does anyone have a better idea on how to get rid of this whitespace? I will keep trying and keep you posted on my findings. Thank you so much!!!
It is because of the line-height taking for all the individual elements. After changing the line-height of the body tag that space will disappear. Below is the code.
body {
line-height: 0.7;
}
As all the elements are having individual line-height you can give even lesser value (<0.7) for line-height of the body tag.
So although the originally accepted answer of using the line-height worked, it messed up all of the line-heights on the page, and after a little bit more tinkering, all that was needed was to add the margin-bottom: -5px; to the canvas element.
This solution is less invasive and achieves the same visual effect, so I will be accepting my own answer as the solution instead. Sorry Masoom!
This is the code now:
<canvas id="matrix" style="margin-left:-20px;margin-bottom:-5px;"></canvas>
Simple html formatting that I just can't seem to gt right.
I have the following div:
<div class="fc-event-time" data-hasqtip="true" aria-describedby="qtip-6">
2:54 - 6:54
<i class="icos-refresh" style="float: right; margin-top: -17px; margin-right: 2px"></i>
<i class="icos-acces-denied-sign" style="float: right; margin-top: -17px; margin-right: 2px"></i>
</div>
that according to firebug has the following css classes acting on it:
padding-left: 5px;
white-space: nowrap;
font-weight: 500;font-size: 12px !important;
padding: 0px 1px;
color: rgb(0, 0, 0) !important;
cursor: pointer;
direction: ltr;
text-align: left
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 18px;
Now the above code is rendering like below:
if you can see, there are two icons on top of one another, the <i></i> elements', my problem is that I would like to have it side by side. My first thought was to adddisplay:block;` but that doesn't work. how can I have them line up rather than superimposed?
UPDATE:
After taking out the margin-top: -17px; I get the following results, but I need them (the text and the icons) to be in the same row.
UPDATE 2:
Finally Figured out the problem and fixed this issue, it turned out to be the 2:54 - 6:54 plain text that was not allowing the <i>s to get in the same line. all I did was modify the Full Calendar source to place the time inside a <span> and gave it a style attribute of `float: left' and its all lined up and working now. Thank you all for helping, if a better answer is submitted (one that I don't need to modify the javascript I will still award it as an answer since that would be a better method.
As far as I can tell you don't have any widths applied to your i icons, plus the negative margin-tops could be playing havock with the floats. If you define actual widths for your i elements you shouldn't have a problem (at least based on what I can see).
If that doesn't work you may also have some kind of absolute positioning involved. If this is the case, and is applied to the i elements, then you'll need to remove it.
But without seeing the style applied to the i elements it's a bit impossible to tell.
update
Ah, ok so the negative top margin was causing the issue. In order to get your text and your icons to align on the same line you'll have to wrap the text with a span and apply a float:left to it.
<span style="display: block; float:left;">2:54 - 6:54</span>
<i class="icos-refresh" style="float: right; margin-right: 2px"></i>
<i class="icos-acces-denied-sign" style="float: right; margin-right: 2px"></i>
However I'd recommend that you not use inline styles and extract these to specific css classes.
I have an input field:
<input type="text" placeholder="whatever">
with styles:
input {
margin: 0;
padding: 0 6px;
font-size: 19px;
line-height: 19px;
height: 36px;
width: 255px;
}
Problem is the line-height is not taking effect for the placeholder in webkit CHROME. so the text in the input field is aligned in an ugly way. Anyone else seen this and now how to fix it?
Thanks
Input placeholders don't seem to like pixel line-height values, but this will vertically centre it in the input:
::-webkit-input-placeholder { line-height: normal; }
Looking at your tags, I'm assuming you are writing something like...
<input type="text" placeholder="whatever">
Unfortunately, Chrome ties your hands when it comes to styling the placeholder, the selector looks like this...
input::-webkit-input-placeholder {}
You can find the styling options, gotchas and supported browsers in Styling the HTML Placeholder
It appears that removing your line-height declaration entirely works. It's worked for me in FF7, Chrome15 and Safari 5.1. Also looked good in IE9 and FF3.6 but does NOT look good in IE8.
I don't think I can fully replicate your problem, but perhaps you can fix it using padding: 7px 6px;.
Doing this should hopefully set your top and bottom padding to 7px which pretty much does a similar job as line-height. With different sizes (width/font-size) you should be able to choose the appropriate padding by calculating (height - fontsize) / 2 perhaps give or take a pixel or two for perfection.