Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS float with min-width and margin
    primarykey
    data
    text
    <p>I was hoping you might be able to help with a problem that's been driving me nuts for a few hours now. I am trying to design a page for a search engine that can add X number of criteria and then perform a search. I'm trying to get the criteria box to re-size depending on the number of criteria, and the screen resolution. I want it to load at an initial size, and then resize itself depending on what's added to it, so that the search button and search results below move downwards. Right now, I can do this using a <code>min-width:100%</code>, but this produces scrollbars and the text overflows onto the right of the page because I'm using a <code>margin-left:340px;</code> to move this box to the right, as there is another box to the left of it, <code>searchList</code>.</p> <p>Removing min-width causes the scroll bars to go away, but then the box is not drawn until an element is added. Adding one element causes a small box to be drawn, and only after adding a few does the whole box go to the right size. Is there some way I can move the box sideways and keeping it in line with the rest of the page, and what is the best way to achieve this?</p> <p>It's the same on both chrome and firefox.</p> <p>The box I'm talking about is <code>&lt;div id="searchCriteria"&gt;&lt;/div&gt;</code>. Full code is below. I would really appreciate any help :)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; body { padding:0px; margin:0px; } #content { min-width:950px; } #header { height:130px; background-color:blue; } #searchList { width: 300px; height: 400px; background-color:green; position:absolute; } #searchCriteria { background-color:red; float:left; min-height:400px; min-width: 100%; margin-left: 340px; } #searchResults { background-color:purple; height: 800px; width: 100%; float:left; } .criteria { border: 1px solid black; padding: 10px; margin: 10px; float: left; width: 400px; } #buttonAndStatus { float:left; background-color:pink; width:100%; text-align:center; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function add(){ $("#searchCriteria").append("&lt;p class=\"criteria\"&gt;This is a bit of search criteria.&lt;/p&gt;"); } &lt;/script&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="header"&gt;fasdfasdfasdf asdf asdf asdf asdf asdf asdf &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="searchList"&gt; &lt;input type="button" name="button" Value="Click me" onClick="add()"&gt; &lt;/div&gt; &lt;div id="searchCriteria"&gt;&lt;/div&gt; &lt;div id="buttonAndStatus"&gt;&lt;input type="button" name="button" Value="Search "&gt;&lt;/div&gt; &lt;div id="searchResults"&gt;asdf asdf asdf asdf &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload