LoginSignup
1
2

More than 5 years have passed since last update.

【SharePoint 2013】SharePoint の Web パーツを開閉する

Last updated at Posted at 2018-11-15

ページに挿入した [スクリプト エディター] の [スニペットを編集] でコードを挿入するだけで、Web パーツが開閉できるようになります。

※jQuery と他のライブラリがコンフリクト(競合)しないようにしています。

<style>
.ms-webpart-chrome h2 {
  position: relative;
  margin: 0 0 4px;
  padding: 0.8em 0 0.8em 1.5em;
  border: 2px solid #993366;
  font-size: 1.143em;
  font-weight: bold;
  background-color: #FFEEFF;
}
.ms-webpart-chrome h2:before {
  content: "";
  position: absolute;
  background: #882255;
  top: 50%;
  left: 0.5em;
  margin-top: -15px;
  height: 30px;
  width: 8px;
  border-radius: 2px;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
}
.ms-webpart-chrome h2:after {
  display: block;
  content: "";
  position: absolute;
  top: 50%;
  right: 10px;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-top: solid 2px #7f7f7f;
  border-right: solid 2px #7f7f7f;
  transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
  transition: .2s;
}
.ms-webpart-chrome .closed h2:after {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
(function ($) {
  $.fn.extend({
    BodyToggle: function (speed) {
      $(this).toggleClass('closed');
      $(this).next().slideToggle(speed);
    },
  });
  $('.ms-webpart-chrome-title').click(function () {
    $(this).BodyToggle('normal');
  });
})(jQuery);
</script>

javaScript

(function ($) {
  $.fn.extend({
    BodyToggle: function (speed) {
      $(this).toggleClass('closed');
      $(this).next().slideToggle(speed);
    },
  });

  $(window).load(function () {
    $('.ms-webpart-chrome-title').click(function () {
      $(this).BodyToggle('normal');
    }).click();// 閉じた状態で開始
  });
})(jQuery);

CSS

.ms-webpart-chrome h2 {
  position: relative;
  margin: 0 0 4px;
  padding: 0.8em 0 0.8em 1.5em;
  border: 2px solid #993366;
  font-size: 1.143em;
  font-weight: bold;
  background-color: #FFEEFF;
}

.ms-webpart-chrome h2:before {
  content: "";
  position: absolute;
  background: #882255;
  top: 50%;
  left: 0.5em;
  margin-top: -15px;
  height: 30px;
  width: 8px;
  border-radius: 2px;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
}

.ms-webpart-chrome h2:after {
  display: block;
  content: "";
  position: absolute;
  top: 50%;
  right: 10px;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-top: solid 2px #7f7f7f;
  border-right: solid 2px #7f7f7f;
  transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
  transition: .2s;
}

.ms-webpart-chrome .closed h2:after {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
}

参考サイト

1
2
0

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
2