Note that there are some explanatory texts on larger screens.

plurals
  1. POCenter a div with a known width with unknown window size
    primarykey
    data
    text
    <p>(Utilizing only css and html for compatibility reasons)</p> <p>I currently have a menu that I'm including on multiple pages (via object with links targeting parent) and I'm trying to center the div horizontally. Using the width of 969px set and margins it centers properly but when the window size becomes too small the menu vanishes completely.</p> <p>Here is the code I've constructed so far:</p> <pre><code>&lt;link href="thestyles.css" rel="stylesheet" media="screen"&gt; &lt;div id='themagic'&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./index.html' target="_top"&gt;&lt;div id='navbutton'&gt;Home&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./HH.html' target="_top"&gt;&lt;div id='navbutton'&gt;Heroin Hypothesized&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./PR.html' target="_top"&gt;&lt;div id='navbutton'&gt;Pain Relief&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./IPF.html' target="_top"&gt;&lt;div id='navbutton'&gt;IPF End-Of-Life Care&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./HAT.html' target="_top"&gt;&lt;div id='navbutton'&gt;Heroin Assisted Treatment&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;a href='./Cited.html' target="_top"&gt;&lt;div id='navbutton'&gt;Works Cited&lt;/div&gt;&lt;/a&gt; &lt;div class='pipe'&gt;|&lt;/div&gt; &lt;/div&gt; </code></pre> <p>As well here is the CSS I've constructed: (Note I've gone through many different approaches to this, none of which yielded the correct results, so some of this may be "throw away")</p> <pre><code>#nav { float:left; width:100%; height:auto; overflow:hidden; } #themagic{ width:969px; margin-left:auto; margin-right:auto; } #navbutton { font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; background: #e8edff; color: #669; display: inline-block; vertical-align: middle; display:-webkit-box; -webkit-box-pack:center; -webkit-box-align:center; display:-moz-box; -moz-box-pack:center; -moz-box-align:center; border-radius: 15px; padding: 15px; float:left; font-size:75%; } #navbutton:hover { background:#D0DAFD; color:#333399; } .pipe { color:#669; float:left; padding:15px; } </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.
    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