Div Contents on one line? - html

How do I get the contents of my DIV to all stay on one line?
I've seen other posts, but I can figure out what I'm doing wrong?
here is a link to the page with an issue:
http://www.heatx.org/productcart/pc/viewCategories.asp?idCategory=2

Given your link start by adding float: left; to #pcIconBarRight img and #pcIconBar a. This should address your question.
EDIT:
Then change this:
And this:
EDIT2:
To display two divs in one row you could do this:
<div style="float: left; width: 200px;">
<div style="float: left; clear: none;">Total: </div>
<div style="float: left; clear: none;">159 USD</div>
</div>
Note: the width: 200px; you should set the width big enough for the inner div's to fit, otherwise it will break the second div to the next line.

I believe the issue is due to the images inside the div. Set display:inline to those images.

Please add this into your bottom of css file
table{
margin: 0 auto;
}
to align your site in center
your menu is not appeared !

A little bit late for answering OP's question. This will be useful for other people having the same problem.
So to get all the elements to appear on a single line the easiest way is:
Set white-space: nowrap;overflow-x: auto; on the parent element.
Set display: inline-block on all child elements.
Result:
Fiddle
<div style="width:100%;white-space:nowrap;overflow-x:auto;border: 1px solid red; border-radius: 10px;padding: 3px;">
<label style="display: inline-block">Some label </label>
<select style="display: inline-block">
<option value="0">aaaaa</option>
<option value="1">bbbbbb</option>
<option value="2">ccccccccc</option>
</select>
<label style="display: inline-block">Another label: </label>
<input type="text" style="display: inline-block;width:200px;" />
<span style="display: inline-block">NOTE: some other text</span>
</div>

Related

how to get label and text to appear on the same line

My label is on one line and text is on the next line. How could I modify the css to make them both on the same line? I have tried several things such as float based on other posts but they still are on different lines.
.indentColumn {
width: 71px;
padding-top: 5%;
}
.labelColumn {
width: 71px;
margin-left: 15%;
}
.inputForm {
margin-left: 30%;
}
<div class="indentColumn">
<div class="labelColumn">
<div class="inputForm">
<span class="secNav">
<label display:inline-block; for="username">#springMessageText("idp.login.username", "User ID:")
</label>
<input class="fieldColumn" display: inline-block; id="username" name="j_username" type="text" size="20" maxlength="64" minlength="6"
value="#if($username)$encoder.encodeForHTML($username)#end">
</span>
</div>
</div>
</div>
Thanks for the help everyone.I removed all the divs, display and also the class in the textbox and now they are on the same line. The main issue seemed to be the class in the textbox because only after I removed that did they appear on the same line.
I also found that there was a form div that was set to 250px that was causing the text field to go onto the next line whenever there was a left-margin. Once I removed that, things started working better.
If you want them on the same line, then put them in a container that is wider than 71 pixels.
There isn't room in 71 pixels for them to fit side by side.
CSS
label{
display:inline-block;
}
and remove <label display:inline-block; ... /> - its wrong

Position well having another well in center of parent container

In my HTML page, I have a well, in which there is another well. The outer well should be in the center of the page, and the inner well in the center of the outer well. My code is given below:
<div id="container">
<div class="col-md-10"></div>
<div class="well col-md-10">
<p> Office name <span class="right-float">Your desk: <span id="desk-id">not set</span> </span></p>
<hr>
<div class="well col-md-6" align="center">
<p> <span class="glyphicon glyphicon-info-sign"></span>
Start your work by setting a name for your Desk</p>
</div>
</div>
<div class="col-md-10"></div>
</div>
It doesn't work; each well appears on the left-side of its respective parent. Does anyone know how I could position them centrally? Thanks in advance!!
Here's my CSS:
hr {
border-color : #474343;
}
.header-dimensions {
width: 110px;
height: 50px;
}
.logoname-dimensions {
display: inline;
width: 115px;
height: 40px;
}
.navbar-pad:{
padding: 0;
}
.right-float{
float: right;
}
What you are trying to do is kind of working against itself.
First off you apply the well class to the same element as the col-md-* element. This results in the whole element floating to the left (from the col-md-* class). You have to make sure that float is overridden in your own code.
Second, you can't use align="center" to center box elements. It works on text, but I think most people would recommend you to keep the centering in the CSS instead of the HTML.
So when you overridden the float and removed the align attribute I suggest you set a new class on both elements that should be centered and add margin: 0 auto; to that class.
Here is a pen that show how it could be done. The align="center" is removed and I've added the class well__centered to the elements. Check the CSS for the styling.

Aligning text boxes with CSS pushes out labels

I'm trying to align a section of text boxes but allowing labels in between them. Unfortunately they are being pushed aside. I'm sure it might be a css field type I'm unaware of that will handle this but maybe someone could help.
<div id="boxalign2">
<p>
<label>Contact Info</label><br>
<label>Email:</label> <input type="text"/>
<label>Office #:</label> <input type="text"/>
<label>Other:</label> <input type="text"/>
<label>Preferred method of contact</label>
<select id = "myList">
<option value = "1">Email</option>
<option value = "2">Phone</option>
</select>
</p>
css
#boxalign2 p label{
display: inline-block;
float: left;
clear: left;
width: 100px;
text-align: right;
}
If the above doesn't show my problem, here is the whole:http://jsfiddle.net/HLLVt/
Hi you don't need the float property in your #boxalign2 p label, also you need to manage the width of the labels and the container depends of what you want.
Chek this fiddle http://jsfiddle.net/HLLVt/4/
Remove the float and clear styles and the <p> tags around each label/input pair and they will all line up on one line. See http://jsfiddle.net/HLLVt/7/

aligning two side-by-side divs screws up table below

I have two divs side by side. I want to align the contents of one to the left and the contents of the other to the right. The left aligns properly but when I align the right, it screws up the input table just below. (See image)
This
Sadly Becomes
This
I feel like this is probably a really simple question but I just can't figure it out, though I swear I've done it before.
Here's the html (I've removed some php loops in the middle of it because I doubt it's relevant but let me know if you think it is):
<div class='uppertitle'>
<div class='question'><h4>What does {$business['name']} aim to achieve within the next three months?</h4></div>
<div class='addRow'><input type="button" value="Add Goal" onclick="addRow('threemonths')" /></div>
</div>
<div class='goals_table'>
<table id="threemonths" class= 'milestones' width="350px" border="1">
<tr>
<td class= 'deleteRow'><input type="button" name="Delete" onClick="newDelete(this);"/> </td>
<td><input type="text" name="txt[]" value='{$goal['description']}'/><input type="hidden" name="type[]" value='threemonths'></td>
</tr>
</table>
</div>
And here's the CSS:
.addRow {
float: right;
display: inline;
}
div#goals .question {
float: left;
margin-left: 40px;
display: inline;
}
.goals_table {
display: block;
}
A sample of the element can be found here: https://dl.dropboxusercontent.com/u/11993667/Hosting%20Signup%20%7C%20%7C%20Page%2010.html
Thanks in advance.
You are going to need this CSS on the table.
clear: both
clear will prevent items from sitting on left, right or both the sides of an element.

I have some HTML that works in a way that seems like it would be impossible. How can this be explained?

I have this HTML:
<div style="width: 100%;">
<div style="float: left; width: 44%; display: inline;">
<img width="95%" height="95%" style="border: none;" src="http://www.problemio.com/img/phoneimage.png">
</div>
<div style="display: inline; float: left; width:54%>">
</div>
</div>
<p>
Some text blah blah
Note that there is nothing in the second div. And what this does is display the text that is below the second closing div in a space next to the image. In other words, it puts it in the space there the empty div is!
How can that be? Is this somehow a bug or is it supposed to be like this?
float is a block,
and you tried to use display: inline in a block is not right
try :
<div style="float: left; width: 44%; display: inline-block;">
You are not clearing the floats so they will continue to float next to other content. Apply a clear fix to the outermost div. Adding overflow: hidden will work, but is antiquated.
http://jsfiddle.net/ExplosionPIlls/nNkJ8/
I don't really understand what you are trying to do :-), but I see this:
On your second div: width:54%>" it should be width:54%" (without the greater than symbol before the quotation mark)
floats and display:inline do not get along together. I would replace both for a display:inline-block like this
<div style="width: 44%; display: inline-block;">
Even though your second div specifies a "width" attribute, if your div is empty, it will be rendered with a width of zero. Try adding a "background-color: red;" to your style to see what I say. You should see nothing.
The text is next to your image because that's what float does. If you want to draw your text below the image you should "clear" your floats. Try this:
<p style="clear:both;">
Some text blah blah
If you decide to try the "display:inline-block" the "clear:both" is not necessary.