Align spans one to each other and center them - html

I want to show a decimal number with currency sign.
The currency and the floating point number should be smaller that the integer part.
For example: $ 4,080,048.00
In the jsFiddle you can see the first line is how I want it to be, but it is written in old HTML style.
I done that with modern HTML (The div with 3 spans) but I have a space between the decimal point: $ 4,080,048. 00.
How can I make the second line to looks like the first one?

Write the markup in a way that there is no space between the spans will fix the problem
<div class="container">
<span class="currency">$</span>
<span class="integer">4,080.</span><span class="decimal">53</span>
</div>
Or, if you don't want to change the markup, you could add font-size:0; to your container class
FIDDLE
.container
{
font-size:0;
}
Yet another option would be to add comments between elements within your markup to make it as if the elements were written one after the other:
FIDDLE
<div class="container">
<span class="currency">$</span><!--
--><span class="integer">4,080.</span><!--
--><span class="decimal">53</span>
</div>

It's the white space which is causing this issue
<div class="container">
<span class="currency">$</span>
<span class="integer">4,080.</span><span class="decimal">53</span>
</div>
http://jsfiddle.net/yrFeB/2/
I cannot add the comment in the answer above but you shouldn't use float: left; for this purpose

Related

Heading and span on the same line

I am generating divs dynamically and need a solution exactly like this (no external style or css because they are ignored when generated dynamically after page load). I don't understand why the browser ignore my text-align:right. Also i want to keep h and span (no p). Normally we should see h to the left and span to the right on the same baseline:
<!DOCTYPE html>
<body>
<div style="background-color:green;color:white;">
<h1 style="display:inline">Green, color of hope</h1>
<span style="text-align:right">I hope to display this to the right</span>
</div>
</body>
</html>
Flexbox can do that:
<div style="background-color:green;color:white; display:flex; justify-content:space-between; align-items:baseline;">
<h1>Green, color of hope</h1>
<span>I hope to display this to the right</span>
</div>
I tuned alot and decide to use this as the simpliest solution to my problem. Note that as many solutions are proposed around the web, rare are those adressing (in a simple way) the problem for items to be baseline aligned while being of different sizes:
<style>
.left{text-align:left;font-size:18px;font-weight:bold;}
.right{float:right;font-size:14px;padding-top:4px}
</style>
<span class='left'>Left</span><span class='right'>Right</span>

text moving out of column in bootstrap

I want to keep the text to move to next line in order to keep it in its own column but my text is overflowing. I want all 1's to stay in 1st col. Any hints on what i might need to change/add?
Heres the code:
<div class="container-fluid ">
<div class="row">
<div class="col-sm-4"> Col1 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
<div class="col-sm-4">Col2</div>
<div class="col-sm-4">Col3</div>
</div>
</div>
Heres the link to how it looks:JSFiddle
.col-sm-4 {
-moz-hyphens:auto;
-ms-hyphens:auto;
-webkit-hyphens:auto;
hyphens:auto;
word-wrap:break-word;
}
This should do the job.
Your problem was, that the browser can't decide where to put a break since you don't have a single space. With hyphens you force him to just break to the next line when there's not enough space. Check here for Browser Support: https://developer.mozilla.org/de/docs/Web/CSS/hyphens#Browser_compatibility
I'm not sure if you want to use CSS "overflow", perhaps checkout this link which will tell you what it is:
http://www.w3schools.com/cssref/pr_pos_overflow.asp
PS: Checkout the Property Values section for the desired end result.
It is css bootstrap default overflow might be not hidden so the text flows use the class col-md-1

Unable to wrap text inside div

I am trying to create an HTML,which should look as follows:-
I am able able to make it but i have a very specific requirement to make it such that when the font size of the first div increases(ie "Gross margin amount'),the div should wrap the text inside it.
But when the font-size of the same increases i get output like follows
Here is my code
<div style="width:132.5px; height:140.5px;background-color:#759BA6;display:block;float:left;margin:3px">
<div style="background-color:#759BA6;width:100%;height:50%;float:top;color: black;">
<span style="font-style:bold;font-size:18.52px;line-height: -moz-block-height;text-align:center;word-wrap: break-word;width:100%;height:100%">Gross Margin Amount</span>
</div>
<div style="background-color:#084C61;font-style:bold;font-size:18.52px;line-height: -moz-block-height;text-align:center;width:100%;height:50%;color: white;float:bottom">
<span style="font-size:13.52px"></span>2,483<span style="font-size:13.52px"></span>
</div>
</div>
Here is the fiddle i have created for reference.
I don't know what should i do to make the first div to wrap text inside it.Any help will be appreciated!
Make height of the div to 100 %:
<div style="width:132.5px; height:100%.5px;background-color:#759BA6;display:block;float:left;margin:3px"><div style="background-color:#759BA6;width:100%;height:100%;float:top;color: black;"><span style="font-style:bold;font-size:28.52px;line-height: -moz-block-height;text-align:center;word-wrap: break-word;width:100%;height:100%">Gross Margin Amount</span></div>
fiddle

Grid is not working properly

I wanted to make a site with the grid system. ( I have made one already, so I know/knew how it works )
This is my custum grid: http://grids.heroku.com/grid.css?column_width=100&column_amount=8&gutter_width=15
And now comes the problem: When I try to put prefix_1 as a class nothing happen it just stays in the same place. And I have one prefix_1 grid_3 and one grid_4. so it is 1+3+4=8. My grid is 8 columns wide so it has to fit together easily, but it doesn't.
http://jsfiddle.net/gekkeabt/5LA82/
<div class="container_8">
<span id="download" class="prefix_1 grid_3"><b>Download</b> Leasy CMS</span>
<span id="download" class="grid_4"><b>Download</b> Macha Webserver</span>
<span id="about" class="prefix_2 grid_4 suffix_2"><b>About</b> Me</span>
</div>
I checked my code 100 times. But I can't find where it went wrong.
Maybe someone can help me out?
Thanks!
EDIT:
I solved the prefix and suffix problem by defining the class in another div outside of the span.
So it looks like:
<div class="prefix_1 grid_3"><span id="download">The content....</span></div>
Try removing the
padding:10px 50px 10px 50px;
line from your #download,#about CSS declaration (or at least the horizontal padding of 2 x 50px).
It's that extra padding that makes the elements wider than one row.
Here's how it looks without that line: http://jsfiddle.net/WHG4u/
Please add this css to your /css/custom.css to make the page stop jumping each time the slide changes
.avia-content-slider-active .slide-entry-wrap { height: 275px; }

Two HTML elements displayed side by side but with in line word wrap

Firstly, sorry about the question title, it may not be very descriptive for my actually requirements (which is one reason why I can't find a solution to this with a Google search - I don't know what to search for)
I am trying to layout some "label text" next to some "value text" but want to keep the value text in line even when it needs to span multiple lines.
Here is an example of the desired result...
Label 1 Value 1
Label 2 Value 2
Label 3 Value 3 is much longer
so it needs to span multiple lines
but should be keep in a nice format
Label 4 Value 4
I know I could easily do this with a table but I don't think a table is appropriate here. Despite what the example data might look like it is not related. Real label examples might be Name, Date, Description, and Reference Number.
I also want to try and avoid using any floating techniques if at all possible - basically because I think using a float would required me to specify a fixed width to ensure a relatively small margin between labels and values.
Other than that I am open to use any elements offered - and of course will use float/tables if they prove to be the best course of action.
Here is a starting JSFiddle of it not working if anybody wants to have a quick play.
Thanks
Try:
HTML
<div class="wrapper">
<span class="Header">Label 1</span>
<span class="Text">Value 1</span>
</div>
<div class="wrapper">
<span class="Header">Label 2</span>
<span class="Text">Value 2</span>
</div>
<div class="wrapper">
<span class="Header">Label 3</span>
<span class="Text">Value 3 is much longer so it needs to span multiple lines but should be keep in a nice format</span>
</div>
<div class="wrapper">
<span class="Header">Label 4</span>
<span class="Text">Value 4</span>
</div>
CSS
.wrapper {
overflow: hidden;
width: 200px; /* just for demo */
}
.Header
{
float: left;
width:100px;
color: #00F;
font-weight: bold;
}
.Text
{
display: block;
overflow: hidden;
}
Demo
http://jsfiddle.net/SGVE5/6/
What you describe looks like tabular data if anything is. So using a simple table is the most logical, the most robust, and most flexible way:
<table>
<tr valign=top><td>label1 <td>value1
...
</table>
This way, you don’t need to be an arbitrary guess on the width of the labels, and changes in font size or text lengths do not play havoc with the page layout. Table formatting automatically allocates as much as needed. And if you need to or wish to, you can set a maximum width, or even a fixed width, for the table as a whole.