HTML / CSS列出职位问题

时间:2015-04-14 22:38:47

标签: html css layout

我试图重新设计几年前为我工作的公司创建的网站。通常我不会在使用现有HTML / CSS重新设计网站时遇到麻烦。但今天我有点麻烦。也许我只需要更多咖啡,但这是我的问题。

我试图让#CSSmenu浮动,并且.promo和.quote向右浮动。似乎#CSSmenu阻止他们向右浮动。它们被强制到div的底部,好像#CSSmenu的总宽度占据整个包装器950px

我附上了一个模拟,以更好地解释我尝试做的事情以及代码。我有一种感觉,它在CSS的某个地方做过这样的事情,但由于我之前没有设计网站,所以在没有评论的情况下找到它有点麻烦。

http://postimg.org/image/ypwpe0fpl/

 <div class="content_width"> <!-- Control Width of wrapper for content -->


        <div id='cssmenu'> <!-- Containter For Nav Menu -->
    <ul>
       <li>Browse Our Products</li> <!--List Title-->

       <li><a href='#'>Business Cards</a></li>
       <li class='active has-sub'><a href='#'>Stationary</a>
            <ul>
             <li class=''><a href='#'>Letter Head</a></li>
             <li class=''><a href='#'>Envelopes</a></li>
             <li class=''><a href='#'>Labels</a></li>
             <li class=''><a href='#'>Note Pads</a></li>
            </ul>
          </li>
       <li><a href='#'>Brochures</a></li>

       <li class='active has-sub'><a href='#'>Signage</a>
            <ul>
             <li class=''><a href='#'>Signs</a></li>
             <li class=''><a href='#'>Yard signs</a></li>
             <li class=''><a href='#'>Trade Show Graphics</a></li>
             <li class=''><a href='#'>X-Frame With Banners</a></li>
            </ul>
          </li>
       <li><a href='#'>Post Cards</a></li>
       <li><a href='#'>Vinyl Banners</a></li>

       <li class='active has-sub'><a href='#'>Mailing Services</a>
            <ul>
             <li class=''><a href='#'>Ink Jet</a></li>
             <li class=''><a href='#'>Direct Mailing</a></li>
             <li class=''><a href='#'>Sorting & Tabbing</a></li>
             <li class=''><a href='#'>Mailing List</a></li>
            </ul>
          </li>

       <li class='active has-sub'><a href='#'>Marketing Material</a>
            <ul>
             <li class=''><a href='#'>Greeting Cards</a></li>
             <li class=''><a href='#'>Rock Cards</a></li>
             <li class=''><a href='#'>Brochures</a></li>
             <li class=''><a href='#'>Book Marks</a></li>
             <li class=''><a href='#'>Presentation Folders</a></li>
            </ul>
          </li>
       <li class='active has-sub'><a href='#'>Speciality Products</a>
            <ul>
             <li class=''><a href='#'>Magnets</a></li>
             <li class=''><a href='#'>T-Shirts (Heat Transfer Imaging)</a></li>
             <li class=''><a href='#'>Bumper Stickers</a></li>
             <li class=''><a href='#'>Plastic</a></li>
             <li class=''><a href='#'>Static Cling</a></li>
            </ul>
          </li>
       <li><a href='#'>Apparel</a>  </li>
    </ul>
    <div class="promo">
      Promo 1
    </div>

    <div class="quote">
    Quote 1
    </div>


    </div><!-- End of Content Wrapper -->

    </div> <!-- End of CSS Menu-->


<style>
/* Added CSS by Darius Shojaei for Content Body */

#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu {
  font-family: Roboto, sans-serif;
}
#cssmenu > ul {
  width: 180px;
  background: #ffffff;
}
#cssmenu > ul > li > a {
  padding: 12px 15px;
  font-size: 14px;
  color: #666666;
  font-weight: 700;
  text-decoration: none;
  -webkit-transition: color .2s ease;
  -o-transition: color .2s ease;
  -ms-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover {
  color: #222222;
}
#cssmenu ul li.has-sub > a::after {
  position: absolute;
  right: 15px;
  display: block;
  width: 10px;
  height: 10px;
  content: "";
  border-radius: 2px;
}
#cssmenu > ul > li.has-sub > a::after {
  top: 14px;
  background: #666666;
}
#cssmenu > ul > li.has-sub:hover > a::after,
#cssmenu > ul > li.has-sub > a:hover::after {
  background: #222222;
}
#cssmenu ul ul li.has-sub > a::after {
  top: 13px;
  background: #ffffff;
}
#cssmenu ul ul li.has-sub:hover > a::after,
#cssmenu ul ul li.has-sub > a:hover::after {
  background: #dddddd;
}
#cssmenu ul li.has-sub > a::before {
  position: absolute;
  right: 15px;
  z-index: 2;
  display: block;
  width: 0;
  height: 0;
  border: 3px solid transparent;
  content: "";
}
#cssmenu > ul > li.has-sub > a::before {
  top: 16px;
  border-left-color: #ffffff;
}
#cssmenu ul ul li.has-sub > a::before {
  top: 15px;
  border-left-color: #2e353b;
}
#cssmenu ul {
  -webkit-perspective: 600px;
  -moz-perspective: 600px;
  perspective: 600px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
#cssmenu ul ul {
  position: absolute;
  top: 0;
  left: -9999px;
  width: 180px;
  background: #2e353b;
  opacity: 0;
  -moz-transition: opacity 0.2s ease, -moz-transform 0.2s ease;
  -webkit-transition: opacity 0.2s ease, -webkit-transform 0.2s ease;
  -ms-transition: opacity 0.2s ease, -ms-transform 0.2s ease;
  -o-transition: opacity 0.2s ease, -o-transform 0.2s ease;
  transition: opacity .2s ease, transform .2s ease;
  -webkit-transform: rotate3d(0, 1, 0, 45deg);
  -moz-transform: rotate3d(0, 1, 0, 45deg);
  transform: rotate3d(0, 1, 0, 45deg);
  -webkit-transform-origin: left center;
  -moz-transform-origin: left center;
  transform-origin: left center;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  backface-visibility: hidden;
}
#cssmenu ul li:hover > ul {
  left: 100%;
  opacity: 1;
  transform: rotate3d(0, 0, 0, 0);
}
#cssmenu ul ul::after {
  position: absolute;
  left: -8px;
  top: 14px;
  z-index: 5;
  display: block;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-right-color: #2e353b;
  content: "";
}
#cssmenu ul ul a {
  padding: 12px 15px;
  font-size: 12px;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  -webkit-transition: color .2s ease;
  -o-transition: color .2s ease;
  -ms-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
  color: #dddddd;
}  

/* End of CSS Vertical Nav Menu */

.promo {
    width:355px;
    background-color:#F0F;
    display:inline;
    float:right;

}
.quote {
    width:355px;
    background-color:#F0F;
    display:inline;
    float:right;

}

.content_width, .content_width_wrapper {
    width: 950px;

    /* Do Not Change This */
    margin: 0px auto;
}





/* end of new CSS */
</style>   

2 个答案:

答案 0 :(得分:1)

看起来你已经把想要漂浮的两件东西(.promo和.quote)放到你想要漂浮的东西上,#CSSMenu。这只是将.promo和.quote浮动到#CSSMenu容器中的 右侧。你需要从#CSSMenu中删除它们,然后将#CSSMenu浮动。

Here's a working demo

更新的代码:

    <div id='cssmenu'> <!-- Containter For Nav Menu -->
<ul>
   <li>Browse Our Products</li> <!--List Title-->

   <li><a href='#'>Business Cards</a></li>
   <li class='active has-sub'><a href='#'>Stationary</a>
        <ul>
         <li class=''><a href='#'>Letter Head</a></li>
         <li class=''><a href='#'>Envelopes</a></li>
         <li class=''><a href='#'>Labels</a></li>
         <li class=''><a href='#'>Note Pads</a></li>
        </ul>
      </li>
   <li><a href='#'>Brochures</a></li>

   <li class='active has-sub'><a href='#'>Signage</a>
        <ul>
         <li class=''><a href='#'>Signs</a></li>
         <li class=''><a href='#'>Yard signs</a></li>
         <li class=''><a href='#'>Trade Show Graphics</a></li>
         <li class=''><a href='#'>X-Frame With Banners</a></li>
        </ul>
      </li>
   <li><a href='#'>Post Cards</a></li>
   <li><a href='#'>Vinyl Banners</a></li>

   <li class='active has-sub'><a href='#'>Mailing Services</a>
        <ul>
         <li class=''><a href='#'>Ink Jet</a></li>
         <li class=''><a href='#'>Direct Mailing</a></li>
         <li class=''><a href='#'>Sorting & Tabbing</a></li>
         <li class=''><a href='#'>Mailing List</a></li>
        </ul>
      </li>

   <li class='active has-sub'><a href='#'>Marketing Material</a>
        <ul>
         <li class=''><a href='#'>Greeting Cards</a></li>
         <li class=''><a href='#'>Rock Cards</a></li>
         <li class=''><a href='#'>Brochures</a></li>
         <li class=''><a href='#'>Book Marks</a></li>
         <li class=''><a href='#'>Presentation Folders</a></li>
        </ul>
      </li>
   <li class='active has-sub'><a href='#'>Speciality Products</a>
        <ul>
         <li class=''><a href='#'>Magnets</a></li>
         <li class=''><a href='#'>T-Shirts (Heat Transfer Imaging)</a></li>
         <li class=''><a href='#'>Bumper Stickers</a></li>
         <li class=''><a href='#'>Plastic</a></li>
         <li class=''><a href='#'>Static Cling</a></li>
        </ul>
      </li>
   <li><a href='#'>Apparel</a>  </li>
</ul>


</div><!-- End of CSS Menu -->
<div class="promo">
  Promo 1
</div>

<div class="quote">
Quote 1
</div>
</div> <!-- End of Content Wrapper-->

CSS:

#cssmenu {
    float:left;
}
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu {
  font-family: Roboto, sans-serif;
}
#cssmenu > ul {
  width: 180px;
  background: #ffffff;
}
#cssmenu > ul > li > a {
  padding: 12px 15px;
  font-size: 14px;
  color: #666666;
  font-weight: 700;
  text-decoration: none;
  -webkit-transition: color .2s ease;
  -o-transition: color .2s ease;
  -ms-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover {
  color: #222222;
}
#cssmenu ul li.has-sub > a::after {
  position: absolute;
  right: 15px;
  display: block;
  width: 10px;
  height: 10px;
  content: "";
  border-radius: 2px;
}
#cssmenu > ul > li.has-sub > a::after {
  top: 14px;
  background: #666666;
}
#cssmenu > ul > li.has-sub:hover > a::after,
#cssmenu > ul > li.has-sub > a:hover::after {
  background: #222222;
}
#cssmenu ul ul li.has-sub > a::after {
  top: 13px;
  background: #ffffff;
}
#cssmenu ul ul li.has-sub:hover > a::after,
#cssmenu ul ul li.has-sub > a:hover::after {
  background: #dddddd;
}
#cssmenu ul li.has-sub > a::before {
  position: absolute;
  right: 15px;
  z-index: 2;
  display: block;
  width: 0;
  height: 0;
  border: 3px solid transparent;
  content: "";
}
#cssmenu > ul > li.has-sub > a::before {
  top: 16px;
  border-left-color: #ffffff;
}
#cssmenu ul ul li.has-sub > a::before {
  top: 15px;
  border-left-color: #2e353b;
}
#cssmenu ul {
  -webkit-perspective: 600px;
  -moz-perspective: 600px;
  perspective: 600px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
#cssmenu ul ul {
  position: absolute;
  top: 0;
  left: -9999px;
  width: 180px;
  background: #2e353b;
  opacity: 0;
  -moz-transition: opacity 0.2s ease, -moz-transform 0.2s ease;
  -webkit-transition: opacity 0.2s ease, -webkit-transform 0.2s ease;
  -ms-transition: opacity 0.2s ease, -ms-transform 0.2s ease;
  -o-transition: opacity 0.2s ease, -o-transform 0.2s ease;
  transition: opacity .2s ease, transform .2s ease;
  -webkit-transform: rotate3d(0, 1, 0, 45deg);
  -moz-transform: rotate3d(0, 1, 0, 45deg);
  transform: rotate3d(0, 1, 0, 45deg);
  -webkit-transform-origin: left center;
  -moz-transform-origin: left center;
  transform-origin: left center;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  backface-visibility: hidden;
}
#cssmenu ul li:hover > ul {
  left: 100%;
  opacity: 1;
  transform: rotate3d(0, 0, 0, 0);
}
#cssmenu ul ul::after {
  position: absolute;
  left: -8px;
  top: 14px;
  z-index: 5;
  display: block;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-right-color: #2e353b;
  content: "";
}
#cssmenu ul ul a {
  padding: 12px 15px;
  font-size: 12px;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  -webkit-transition: color .2s ease;
  -o-transition: color .2s ease;
  -ms-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
  color: #dddddd;
}  

/* End of CSS Vertical Nav Menu */

.promo {
    width:355px;
    background-color:#F0F;
    display:inline;
    float:right;

}
.quote {
    width:355px;
    background-color:#F0F;
    display:inline;
    float:right;

}

.content_width, .content_width_wrapper {
    width: 950px;

    /* Do Not Change This */
    margin: 0px auto;
}

答案 1 :(得分:0)

如果您希望它“漂浮”在页面上的设定位置,请尝试

position:fixed;
top:somepixels;
left:somepixels;
etc