Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="w-100 bg-dark d-flex justify-content-between align-items-center p-2">
  <button class="btn bg-transparent text-white"><i class="fa fa-bars" aria-hidden="true"></i></button>
  <h1 class="text-white">LOGO</h1>
  <div id="search-wrap" class="d-flex search-wrap position-relative">
    <form action="#" id="form" class="position-absolute d-flex form h-100">
      <button id="search-btn" class="btn search-btn bg-transparent border-0 text-white"><i class="fa fa-search" aria-hidden="true"></i></button>
      <input placeholder="Search..." id="search-text" class="search-text bg-transparent">
      <span id="text-under-line" class="text-under-line position-absolute"></span>
    <button id="close-btn" class="btn btn-danger close-btn bg-transparent border-0"></button>


                button {
  cursor: pointer;

button {
  outline: none;

.form {
  overflow: hidden;//.formの領域からはみ出た部分を隠す
  top: 0;
  right: 50%; //虫眼鏡が現在地からそのまま移動するように調節
  //visibility: hidden;
  transition: all 0.1s linear;
  width: 0;
  &.is-open {

.close-btn {
  z-index: 2;

.search-text {
  border: none;
  border-bottom: 1px solid white;
  //width: 100%; //absoluteで左右ぴったりに配置するために100%にしている※なくても正常に動作した
  &:focus ~ .text-under-line {//フォーカスされるとラインが広がるようにする
    transform: scaleX(1);

.text-under-line {
  border-bottom: 2px solid white;
  height: 2px;
  bottom: 0;
  transition: all 0.1s linear;
  transform: scaleX(0);//始めはラインを隠す

.ov-v {
  overflow: visible;

.ov-h {
  overflow: hidden;



                (function() {
  const searchBtn = document.getElementById("search-btn");
  const searchText = document.getElementById("search-text");
  const closeBtn = document.getElementById("close-btn");
  const form = document.getElementById("form");
  const textUnderLine = document.getElementById("text-under-line");

  closeBtn.innerHTML = '<i class="fa fa-search" aria-hidden="true"></i>';

  function getPropertyValue(elem, property) {
    const computedStyle =
      elem.currentStyle || document.defaultView.getComputedStyle(elem, ""); //currentStyleはIE,getComputedStyleはそれ以外
    const propertyValue = computedStyle.getPropertyValue(property);
    return propertyValue;

    e => {
      if (form.classList.contains("is-open")) {
        closeBtn.innerHTML = '<i class="fa fa-times" aria-hidden="true"></i>'; = "auto";//#search-textのブラウザが示す小数点を含む幅を取得するためにwidthをautoにする
        // = searchText.offsetWidth + 'px';
        const searchTextWidth = getPropertyValue(searchText, "width");//#search-textのブラウザが示す小数点を含む幅を取得する
        const searchBtnWidth = getPropertyValue(searchBtn, "width");//#search-btnのブラウザが示す小数点を含む幅を取得する
        //console.log(parseFloat(searchTextWidth) + parseFloat(searchBtnWidth)); =
          parseFloat(searchTextWidth) + parseFloat(searchBtnWidth) + "px";//#search-textの幅+#search-btnの幅を#formの幅にしてtransitionが効くようにする。width:auto;では効かないためこのようなことをしている。 = searchTextWidth;//#text-under-lineの幅を#search-textの幅にする
        //leftとrightで左右ぴったりに配置 = searchText.getBoundingClientRect().left - searchBtn.getBoundingClientRect().left + "px"; //#search-btnの座標から数えた#search-textの相対座標※追記:rightのみでも良かった = 0 + "px"; = 0; //#formの右端を×アイコンの右端に揃える
      } else {
        closeBtn.innerHTML = '<i class="fa fa-search" aria-hidden="true"></i>'; = ""; //position:absolute;で配置しているため、閉じる直前に指定しないとぴったりと収まっていないため、吸収場所がボタン領域内ではなく画面外となってしまう。 = ""; = "";//追記:書かなくても動作した = "";//追記:書かなくても動作した = ""; = "";