Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix the width with css?
    primarykey
    data
    text
    <p>I want to implement a "center frame" like a narrow and tall page in the center of my webpage. And I want to make sure it has 200 pixels of space both in left and right. The following css rule works for left, but right is nearly on the right of body.</p> <pre><code>div#centerframe { background:rgba(255, 255, 255, 0.85); box-shadow:0em 0.5em 2em 0.3em; margin-left: 200px; margin-top: 200px; /* top works too */ margin-right: 200px; float:left; /* because I want it to expand with its content */ padding-top: 90px; padding-bottom: 90px; padding-left: 90px; padding-right: 90px; } </code></pre> <p>I made a fiddle to show you the bad behaviour, but it behaves as I want in this fiddle : <a href="http://jsfiddle.net/UMscz/" rel="nofollow">http://jsfiddle.net/UMscz/</a></p> <p>however, with the same dom, it doesn't work on my site.</p> <p>the body rule is like this :</p> <pre><code>body { position:relative; width:100%; height:100%; padding:0; margin:0; overflow:auto; } </code></pre> <p>and my dom is like </p> <pre><code>&lt;body&gt; &lt;div id='centerframe'&gt; &lt;div id='article_wrapper'&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>So how can I make sure that <code>'#centerframe'</code> has a certain pixels of space in right and left ?</p> <p>The reason I'm trying to do is I want to show fixed size ads on the page.</p> <p>Thanks !</p> <h2>Edit :</h2> <p>And I'm sure that nothing in the content "pushes" it to stretch. I don't set any <code>width</code> rules in the content so that it resizes according to centerframe and its padding.</p> <h2>Edit 2:</h2> <p>I spotted the problem. But it is still strange. I had some elements that pushes its width, in index.php (inline style). But when I click to a link, and go to show_article.php, the width of the centerframe remains as in the index.php.</p> <p>So when I removed the width rule in index.php, it also fixed the width in show_article.php, even though the width rule was only in index.php.</p> <p>So, does the css rule remain when going to another page? It shouldn't, right ?</p>
    singulars
    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.
    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