I'm modifying the header portion of a WordPress theme and I'm trying to nest a couple divs within another div. I'm not very experienced with HTML/CSS, but what I'm observing seems weird to me.
My code looks like this:
<div class="extras">
<div id="search">
<form role="search" method="get" id="searchform" action="http://mentatescholars.com/" >
<input type="search" placeholder="Search" value="" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</form>
</div><!-- end #search -->
<div class="phone-number">
<div class="phone-number-main">1-885-MENTATE</div>
<div class="phone-number-sub">1-885-636-8283</div>
</div>
</div>
And in the picture I have the phone-number div selected with Firefox's inspector (selecting extras looks the same). What strikes me as odd is why it's starting at the top of the extras div and not after the search div. search even has a set height of 40px.
If I select the third div, then the it shows the div starting right after the previous div.
What also strikes me as odd is how, while the top of the phone-number-main div is flush with extras, the text shifts down perfectly without me doing anything.
My question is this: How can I make it so that the phone-number div starts right after the search div?
Here's the site, if you want to look at it: http://mentatescholars.com/.
#search is floated and the .phone-number isn't.
If you add clear:both to the .phone-number <div /> you will see the correct layout.
float removes elements from the flow of the document. Check uot this link for more info: http://www.alistapart.com/articles/css-floats-101/
that is because you have floated element. your "search" div is floated and has no clear. Use clear:both in the CSS of the phone-number element and it will work fine
And if you want the number to be right after search make the height of search 30px and get rid of the submit button's margin bottom.
make #search block smaller by reducing height, lets say to 30px.
Related
It appears that it's awkward if you need a fluid-width text field with an add-on in Bootstrap 2.3.2.
If the containing div becomes smaller than the input field, an input with a span12 class on it will resize quite happily.
However, doing the same to this snippet is a bit more difficult
<div class="input-append">
<input type="text">
<span class="add-on">Sheep</span>
</div>
Does anyone have a solution to this?
Here's a fiddle: http://jsfiddle.net/KFr2z/149/
If you have input alone it is very easy to expand it to fit parent. It is also easy for more than one element if other has % width. Problem become if you have more than one element and other elements has fixed width or no explicitly determined width at all. Then you need an element which fit all parent's remaining space. From what I know it is impossible to make input to behave that way. But any native block-level element enclosing input should do the trick:
<div class="input-append">
<span class="add-on" style="float: right;">Sheep</span>
<div style="overflow: hidden;">
<input type="text" class="span12">
</div>
</div>
Bootstrap use some styles based on childs' order so you should also setborder-radius: 0 3px 3px 0 because it doesn't apply to add-on any more.
Quick CSS Question. I cannot seem to figure out a very simple CSS/HTML problem. Here's a JSFiddle.
http://jsfiddle.net/BmM6t/
Basically, these two divs are not resizing to anything less than 100% width:
<div id="main_pic" class="main_div">
THIS IS WHERE THE MAIN PIC WILL GO.
</div>
<div id="signin" class="main_div">
SIGN IN TO THE SITE!
<form>
<label for="name">EMAIL/USERNAME:</label>
<input type="text" name="name" id="name">
<label for="email">PASSWORD:</label>
<input type="text" name="email" id="email">
<br />
<input type="submit" value="Let's Play!">
</form>
</div>
You'll see that the two divs with class main_div actually take up the entire width of the screen for some reason (you can see that if you inspect the element) even though their widths are clearly written. When you try to change the width of one of the main_div's it changes the width but if you inspect the element, it just changes the width of the object and adds padding around it to make sure it still takes up the entire width of the screen.
I'm sure it's some little error I've made but I can't find it. Thanks for the help!
That's how divs work, they are block level elements. If you don't want them to take up the entire with of its container element you can float it or make it inline-block
Use a overflow: hidden; to the .main_div so that you can see that it is resizing but not hiding the contents.
I am trying to position some text within a div which contains a background image. How do I go about with this. The site has to be responsive. Something like the right section on this site. http://loveandluxesf.com/
So this is the following code.
<div class="row">
<div class="six columns" id="signup-section">
<div id="bg-img">
<div class="offset-by-two">
<h2>Random text which should go in here</h2>
<form>
<input type="email">
<span class="button">Register</span>
</form>
</div>
</div>
</div>
bg-img contains a background image which is centered. I want the text and the form to fit exactly inside the image. And this should work across multiple resolutions.
If you relatively position your containing div, then absolutely position the text element (h1), you can use top left right bottom positioning to put the text where you like relative to the containing div. If you need more specifics just ask.
try to set style="float:left;"
I'd like to center a submit button. How do I accomplish this? I dont know the width of the button, it may be flexible based on the text inside it. I'm trying not to use float and set the margin auto on it because that will require a width.
<input type="submit" value="may vary" />
If the width is variable, your best bet is to use the text-align property of the container. If that would effect other sibling elements in an undesirable way, consider wrapping the input in a div.
<div style="text-align: center">
<input type="submit" value="may vary" />
</div>
NOTE: The inline CSS above is just an example, feel free to create a css rule for the div.
I have a div inside a field set that looks like this:
<fieldset>
<legend>Device</legend>
<label id="select-6-container">
<select id="select-6" name="device_select" style="display:none"></select>
</label>
</fieldset>
<div id="ctrl">
<button type="button" id="restart1" name="button1" onclick="window.location.reload()" value="Restart Wizard">Restart Wizard</button>
<button type="button" id="gotostep2" class="gotostep2" name="button1" value="Next Step">Next Step</button>
</div>
My select box is populated with YUI and then shown (notice that its hidden on load). My CSS for the box looks like this:
#ctrl {
margin-top: 102px;
margin-left: -200px;
position: absolute;
width:100px;
}
But when My select box is generated, the ctrl box moves down everytime! Do I have my CSS wrong? Or is it because the select box is generated by Javascript after the page has loaded?
I should mention that when YUI renders the select box as a menu button it changes it's markup to be a button, I didn't think this should matter because the positioning of ctrl is what I'm trying to change.
Any advice would help!
Thanks!
Your div doesn't seem to be inside the fieldset, as you had mentioned.
Try to assign a position to the div using top, right, bottom and/or left. The div's position will be then depending on the next positioned parent element, so have an eye on that as well.
If all of this doesn't work — please post as well the surrounding mark–up and CSS.