CSS按钮添加顶部栏

时间:2017-06-21 18:45:56

标签: html css button

我有使用HTML,CSS和JavaScript创建的信息框的代码以及几个按钮。如何在我的每个按钮顶部制作一个绿色小条,类似于我在信息框顶部的条形图?有谁知道我怎么能做到这一点?任何事都有帮助,欢呼。

.everything {
  text-align:center;
  min-height:775px;
}

.everything:hover {
cursor: default;
}

#wrapper {

    margin: 0 auto;
}
#wrapper img{
    width:100%;
}

.infobox-list {
    display: inline-block;
    text-align: center;
}

ul, ol, li {
    margin: 0;
    padding: 0;
    list-style-position: outside;
    list-style-type: none;
}

h1, h2, h3, h4, h5, h6, ul, li, ol, form, fieldset {
    margin: 0;
    padding: 0;
}

*, *:before, *:after {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

ul, menu, dir {
    display: block;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 0px;
}

.hr {
  border-color:rgba(255,255,255,0.3);
  width: 210px;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    padding: 0;
    margin: 0;
    background-color: #fff;
    color: #555;
    min-width: 20em;
}

.info-boxes li {
  width: 320px;
    height: 550px;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(21,100,102,0.35);
    border-radius: 4px;
    margin: 0 0px 0px;
    position: relative;
    overflow: hidden;
    transform: scale(0.75); 
}

.ptext
{
  font-family:Verdana;
  text-align:center;
  font-size:24px;
  color:#156466;

}

.profile
{
  margin-top:10%;
  margin-left:1px;
  width:85px;
  height:85px;
}

.learning
{
  margin-top:10%;
  width:85px;
  height:85px;
}

.performance
{
  margin-left:1px;
  margin-top:10%;
  width:85px;
  height:85px;
}

.team
{
  margin-top:10%;
  width:85px;
  height:85px;
}

.smallicons
{
  width:60px;
  height:60px;
}

.close {
  font-size:25px;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor:pointer;
  left: 0;
  padding: 2.35rem;
  text-align: center;
}

.open {
  font-size:25px;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor:pointer;
  left: 0;
  padding: 1rem;
  text-align: center;
}

.openimg {
  height:20px;
  width:20px;
}

.closeimg {
  height:20px;
  width:20px;
}

.infobox-list li {
  display: inline-block;
}

a {
  color: white;
  text-decoration: none;
  font-weight:lighter;
}

.info-boxes li .infobox {
  display: table-cell;
  cursor:default;
  text-align:center;
  vertical-align: middle;
  height: 550px;
  width: 320px;
}

.info-boxes li .infobox:before { 
  content: '';
  position: absolute;
  left: 20%;
  width: 160%; 
  height: 188%; 
  background-color: rgb(255, 255, 255); /* fallback */
  background-color: rgba(255, 255, 255, 0.2);
  top: 0;
  -webkit-transform: rotate(46deg);
  -moz-transform: rotate(46deg);
  transform: rotate(30deg);
} 

.info-boxes li.hover .shade {
  animation-name: windowshade;
  cursor:default;
}

.info-boxes li .shade,
.info-boxes li.hover .shade {
  animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  animation-duration: 1s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

section p {
  line-height: 1.3em;
  color: #6d6e71;
  width: 100%;
  padding: 0 10px;
  margin-top: 5px;
  margin-left: 0px;
  text-align:left;
}

p {
  display: block;
}

.info-boxes li .shade {
  position: absolute;
  width: 320px;
  height: 570px;
  left: 0;
  top: 0;
  background-color: #156466;
  color: #fff;
  display: table;
  vertical-align: middle;
  padding: 20px 10px 0;
  transform: translateY(-340px);
  animation-name: windowshade-out;
}

.info-boxes li .shade h3 {
  color: #fff;
  padding: 10px;
  font-weight: bold
}

.info-boxes li .shade p {
  color: #fff;
  margin-top:23px;
  line-height: 1.5em;
  font-weight: lighter;
}

section a {
  line-height: 2em;
  color: #6d6e71;
  width: 100%;
  padding: 0 10px;
  margin-top: 13px;
  margin-left: 0px;
  text-align:left;
}

a {
  display:block;
}

.info-boxes li .shade a {
  text-align:left;
  color: #fff;
  line-height: 1.5em;
  font-weight: lighter;
}

.info-boxes li .shade a:hover {
text-decoration:underline;
}

.ie9 .info-boxes li.hover .shade {
  top: 245px
}

.info-boxes li.hover a {
  text-decoration: none
}

@keyframes windowshade {
  0% {
    transform: translateY(-550px)
  }
  100% {
    transform: translateY(0)
  }
}

@keyframes windowshade-out {
  0% {
    transform: translateY(0)
  }
  100% {
    transform: translateY(-550px)
  }
}

.button_slide {
  color: #156466;
  border: 1px solid rgba(21,100,102,0.35);
  border-radius: 0px;
  padding: 18px 30px;
  display: inline-block;
  font-family: Verdana;
  font-size: 14px;
  margin-bottom:20px;
  letter-spacing: 1px;
  background-color: rgba(255,255,255,0.3);
  cursor: pointer;
  box-shadow: inset 0 0 0 0 #156466;
  -webkit-transition: ease-out 0.4s;
  -moz-transition: ease-out 0.4s;
  transition: ease-out 0.4s;
}

.slide_down:hover {
  color:white;
  border: 1px solid transparent;
  box-shadow: inset 0 100px 0 0 #156466;
}

.button_slidehr {
  color: #156466;
  border: 1px solid rgba(21,100,102,0.35);
  border-radius: 0px;
  /* extend left padding */
  padding: 18px 15px 18px 62px;
  position: relative;
  display: inline-block;
  font-family: Verdana;
  font-size: 14px;
  margin-bottom: 20px;
  letter-spacing: 1px;
  background-color: rgba(255,255,255,0.3);
  cursor: pointer;
  box-shadow: inset 0 0 0 0 #156466;
  -webkit-transition: ease-out 0.4s;
  -moz-transition: ease-out 0.4s;
  transition: ease-out 0.4s;
}

.slide_downhr:hover {
  color:white;
  border: 1px solid transparent;
  box-shadow: inset 0 100px 0 0 #156466;
}

.button_slidehr:after {
  content: "";
  display: inline-block;
  position: absolute;
  left: 10px;
  top: 0;
  width: 100%;
  height: 100%;
  background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498058230/HR-Connect-Logo_hjbrmn.png);
  background-position: left center;
  background-repeat: no-repeat;
  background-size: auto 80%;
}

.slide_downhr:hover:after {
  background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498065514/iconhr_oz4fvo.png);
}

.open::before {
content: "";
background: url("http://res.cloudinary.com/djxai1v1e/image/upload/v1498056439/Close-Icon_ra8vcj.png");
height: 20px;
width: 20px;
display: inline-block;
background-size: contain;
}
.close::before {
content: "";
background: url("http://res.cloudinary.com/djxai1v1e/image/upload/v1498057420/opend-icon_nrulip.png");
height: 20px;
width: 20px;
display: inline-block;
background-size: contain;
}
<div class="everything">
  <br style="line-height:15px;">
  <section class="info-boxes">
    <ul class="infobox-list">
      
      
      <li>
        <a href="javascript:void(0);">
          <div class="infobox">
            <table>
              <tr>
                <img class="profile" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497467825/Profile-Icon_oy7oxz.png"></tr>
              <tr>
                <p class="ptext">My Profile</p>
              </tr>
            </table>
            <div class="open"></div>
          </div>
          <div class="shade">
            <table>
              <tr>
                <td>
                  <img class="smallicons" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497301295/About-Me_dudglr.png">
                </td>
                <td>
                  <a href="https://northwestcomp.stage.sumtotal.host/Core/dash/profile/personalProfileManager?userid=NWTMP0001">About Me</a>
                  <hr class="hr">
                </td>
              </tr>
              <tr>
                <td><img class="smallicons" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497284615/Resume_tb7t02.png"> </td>
                  <td>
                    <a href="https://northwestcomp.stage.sumtotal.host/Core/person/resume?userid=NWTMP0001">Resume</a>
                    <hr class="hr">
                  </td>
              </tr>
              <tr>
                <td><img class="smallicons" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497280574/Accountabilities_qfdcns.png"> </td>
                  <td>
                    <a href="">Accountabilities
                    </a>
                      <hr class="hr">
                  </td>
              </tr>
              <tr>
                <td><img class="smallicons" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497970831/Chnage-Password-Icon_noszkb.png"> </td>
                  <td>
                    <a href="https://northwestcomp.stage.sumtotal.host/Core/changepassword">Change Password</a>
                    <hr class="hr">
                  </td>
              </tr>
              <tr>
                <td><img class="smallicons" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1497970831/Sign-Out-Icon_twkoy7.png"> </td>
                  <td>
                    <a href="https://northwestcomp.stage.sumtotal.host/Broker/Account/Login.aspx?wtrealm=https%3a%2f%2fNORTHWESTCOMP.stage.sumtotal.host%2fcore%2f&ReturnUrl=http%3a%2f%2fnorthwestcomp.stage.sumtotal.host%2fbroker%2fToken%2fSaml11.ashx%3fwa%3dwsignin1.0%26wtrealm%3dhttps%253a%252f%252fNORTHWESTCOMP.stage.sumtotal.host%252fcore%252f%26wreply%3dhttps%253a%252f%252fnorthwestcomp.stage.sumtotal.host%252fCore%252f%252f&domainid=52160A28FC58BBBE7D714E075077AC76">Sign Out</a>
                    <hr class="hr">
                  </td>
              </tr>
            </table>
            <div class="close"></div>
          </div>
        </a>
      </li>
      </ul>
      </section>
        <div class="button_slide slide_down">myPATH User Guide</div>
   <div class="button_slidehr slide_downhr">Contact HR Now></div>
      </div>

1 个答案:

答案 0 :(得分:1)

您只需在按钮span内添加div并完全定位即可。

要做到这一点,我修改了代码,方法是将position:relative;添加到button_slide类,在按钮<span class="button_slide_top">&nbsp;</span>中添加div,然后添加新类{{1}在css部分的底部。

您可以使用button_slide_top类调整条形的高度。

button_slide_top
.everything {
  text-align:center;
  min-height:775px;
}

.everything:hover {
cursor: default;
}

#wrapper {

    margin: 0 auto;
}
#wrapper img{
    width:100%;
}

.infobox-list {
    display: inline-block;
    text-align: center;
}

ul, ol, li {
    margin: 0;
    padding: 0;
    list-style-position: outside;
    list-style-type: none;
}

h1, h2, h3, h4, h5, h6, ul, li, ol, form, fieldset {
    margin: 0;
    padding: 0;
}

*, *:before, *:after {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

ul, menu, dir {
    display: block;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 0px;
}

.hr {
  border-color:rgba(255,255,255,0.3);
  width: 210px;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    padding: 0;
    margin: 0;
    background-color: #fff;
    color: #555;
    min-width: 20em;
}

.info-boxes li {
  width: 320px;
    height: 550px;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(21,100,102,0.35);
    border-radius: 4px;
    margin: 0 0px 0px;
    position: relative;
    overflow: hidden;
    transform: scale(0.75); 
}

.ptext
{
  font-family:Verdana;
  text-align:center;
  font-size:24px;
  color:#156466;

}

.profile
{
  margin-top:10%;
  margin-left:1px;
  width:85px;
  height:85px;
}

.learning
{
  margin-top:10%;
  width:85px;
  height:85px;
}

.performance
{
  margin-left:1px;
  margin-top:10%;
  width:85px;
  height:85px;
}

.team
{
  margin-top:10%;
  width:85px;
  height:85px;
}

.smallicons
{
  width:60px;
  height:60px;
}

.close {
  font-size:25px;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor:pointer;
  left: 0;
  padding: 2.35rem;
  text-align: center;
}

.open {
  font-size:25px;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor:pointer;
  left: 0;
  padding: 1rem;
  text-align: center;
}

.openimg {
  height:20px;
  width:20px;
}

.closeimg {
  height:20px;
  width:20px;
}

.infobox-list li {
  display: inline-block;
}

a {
  color: white;
  text-decoration: none;
  font-weight:lighter;
}

.info-boxes li .infobox {
  display: table-cell;
  cursor:default;
  text-align:center;
  vertical-align: middle;
  height: 550px;
  width: 320px;
}

.info-boxes li .infobox:before { 
  content: '';
  position: absolute;
  left: 20%;
  width: 160%; 
  height: 188%; 
  background-color: rgb(255, 255, 255); /* fallback */
  background-color: rgba(255, 255, 255, 0.2);
  top: 0;
  -webkit-transform: rotate(46deg);
  -moz-transform: rotate(46deg);
  transform: rotate(30deg);
} 

.info-boxes li.hover .shade {
  animation-name: windowshade;
  cursor:default;
}

.info-boxes li .shade,
.info-boxes li.hover .shade {
  animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  animation-duration: 1s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

section p {
  line-height: 1.3em;
  color: #6d6e71;
  width: 100%;
  padding: 0 10px;
  margin-top: 5px;
  margin-left: 0px;
  text-align:left;
}

p {
  display: block;
}

.info-boxes li .shade {
  position: absolute;
  width: 320px;
  height: 570px;
  left: 0;
  top: 0;
  background-color: #156466;
  color: #fff;
  display: table;
  vertical-align: middle;
  padding: 20px 10px 0;
  transform: translateY(-340px);
  animation-name: windowshade-out;
}

.info-boxes li .shade h3 {
  color: #fff;
  padding: 10px;
  font-weight: bold
}

.info-boxes li .shade p {
  color: #fff;
  margin-top:23px;
  line-height: 1.5em;
  font-weight: lighter;
}

section a {
  line-height: 2em;
  color: #6d6e71;
  width: 100%;
  padding: 0 10px;
  margin-top: 13px;
  margin-left: 0px;
  text-align:left;
}

a {
  display:block;
}

.info-boxes li .shade a {
  text-align:left;
  color: #fff;
  line-height: 1.5em;
  font-weight: lighter;
}

.info-boxes li .shade a:hover {
text-decoration:underline;
}

.ie9 .info-boxes li.hover .shade {
  top: 245px
}

.info-boxes li.hover a {
  text-decoration: none
}

@keyframes windowshade {
  0% {
    transform: translateY(-550px)
  }
  100% {
    transform: translateY(0)
  }
}

@keyframes windowshade-out {
  0% {
    transform: translateY(0)
  }
  100% {
    transform: translateY(-550px)
  }
}

.button_slide {
  position: relative;
  color: #156466;
  border: 1px solid rgba(21,100,102,0.35);
  border-radius: 0px;
  padding: 18px 30px;
  display: inline-block;
  font-family: Verdana;
  font-size: 14px;
  margin-bottom:20px;
  letter-spacing: 1px;
  background-color: rgba(255,255,255,0.3);
  cursor: pointer;
  box-shadow: inset 0 0 0 0 #156466;
  -webkit-transition: ease-out 0.4s;
  -moz-transition: ease-out 0.4s;
  transition: ease-out 0.4s;
}

.slide_down:hover {
  color:white;
  border: 1px solid transparent;
  box-shadow: inset 0 100px 0 0 #156466;
}

.button_slidehr {
  color: #156466;
  border: 1px solid rgba(21,100,102,0.35);
  border-radius: 0px;
  /* extend left padding */
  padding: 18px 15px 18px 62px;
  position: relative;
  display: inline-block;
  font-family: Verdana;
  font-size: 14px;
  margin-bottom: 20px;
  letter-spacing: 1px;
  background-color: rgba(255,255,255,0.3);
  cursor: pointer;
  box-shadow: inset 0 0 0 0 #156466;
  -webkit-transition: ease-out 0.4s;
  -moz-transition: ease-out 0.4s;
  transition: ease-out 0.4s;
}

.slide_downhr:hover {
  color:white;
  border: 1px solid transparent;
  box-shadow: inset 0 100px 0 0 #156466;
}

.button_slidehr:after {
  content: "";
  display: inline-block;
  position: absolute;
  left: 10px;
  top: 0;
  width: 100%;
  height: 100%;
  background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498058230/HR-Connect-Logo_hjbrmn.png);
  background-position: left center;
  background-repeat: no-repeat;
  background-size: auto 80%;
}

.slide_downhr:hover:after {
  background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498065514/iconhr_oz4fvo.png);
}

.open::before {
content: "";
background: url("http://res.cloudinary.com/djxai1v1e/image/upload/v1498056439/Close-Icon_ra8vcj.png");
height: 20px;
width: 20px;
display: inline-block;
background-size: contain;
}
.close::before {
content: "";
background: url("http://res.cloudinary.com/djxai1v1e/image/upload/v1498057420/opend-icon_nrulip.png");
height: 20px;
width: 20px;
display: inline-block;
background-size: contain;
}
.button_slide_top {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    height: 10px;
    background-color: #156466;
}