LoginSignup
1

More than 3 years have passed since last update.

bootstrapでプラスからマイナスへ変化するアイコンを作る

Posted at

最近

最近はコロナのせいで引きこもっています。楽しみがパンケーキを作ることしかないです。何かちょうど良い趣味教えてください。

bootstrapでプラスからマイナスに変化するアイコンを作る

まずはHTML

index.html
<div class="" id="collapseListGroupHeading">
  <a href="#switch" class="collapsed" data-toggle="collapse"></a>
  <div class="collapse" id="switch" aria-expanded="false">
  </div>
</div>

そしてCSS

style.css
#collapseListGroupHeading a[data-toggle="collapse"]{
  padding: 10px;
  text-decoration: none;
  position: relative;
}
#collapseListGroupHeading a[data-toggle="collapse"]::before,
#collapseListGroupHeading a[data-toggle="collapse"]::after{
  content:"";
  width: 8px;
  height: 0;
  border-top: #000000 1px solid;
  border-bottom: #000000 1px solid;
  position: absolute;
  right: 15px;
  top: 12px;
  bottom: 12px;
  margin: auto;
}
#collapseListGroupHeading a[aria-expanded=false]::after{
  -webkit-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  transition-duration: 0.3s;
}
#collapseListGroupHeading a[aria-expanded=true]::after{
  -webkit-transform: rotate(0deg);
  -ms-transform: rotate(0deg);
  transform: rotate(0deg);
  transition-duration: 0.3s;
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1