bulma icon indicating copy to clipboard operation
bulma copied to clipboard

is-fullwidth in dropdown button

Open willianferreiradev opened this issue 5 years ago • 17 comments

This is a feature request for Bulma CSS framework

Description

Add is-fullwidth to the dropdown button. I'm trying to make a home, and I need to have a dropdown on certain buttons. However when I use the dropdown the is-fullwidth property does not apply to it.

captura de tela_2018-08-16_08-38-27

willianferreiradev avatar Aug 16 '18 11:08 willianferreiradev

Please Check this:

<div class="dropdown is-active">
  <div class="dropdown-trigger">
    <button class="button" aria-haspopup="true" aria-controls="dropdown-menu2">
      <span>Content</span>
      <span class="icon is-small">
        <i class="fas fa-angle-down" aria-hidden="true"></i>
      </span>
    </button>
  </div>
  <div class="dropdown-menu" id="dropdown-menu2" role="menu">
    <div class="dropdown-content">
      <div class="dropdown-item">
        <p>You can insert <strong>any type of content</strong> within the dropdown menu.</p>
      </div>
      <hr class="dropdown-divider">
      <div class="dropdown-item">
        <p>You simply need to use a <code>&lt;div&gt;</code> instead.</p>
      </div>
      <hr class="dropdown-divider">
      <a href="#" class="dropdown-item">
        This is a link
      </a>
    </div>
  </div>
</div>

Custom CSS:

.dropdown {
  width: 100%;

  .dropdown-trigger {
    width: 100%
  }

  .button {
    display: flex;
    width: 100%;
    justify-content: space-between
  }

}

While we have an official response, you can play with the CSS. Work for me.

andrefedev avatar Aug 19 '18 05:08 andrefedev

I ended up doing my own dropdown using the normal button. But I'll try to add this and see how it goes. Thank you for your help!

willianferreiradev avatar Aug 21 '18 11:08 willianferreiradev

I need the same thing. Could you please consider adding this class, to avoid fiddling too much with the CSS? This works fine:

.dropdown.is-fullwidth {
  display: flex;

  .dropdown-trigger,
  .dropdown-menu {
    width: 100%;
  }
}

@andreolaya Do we really need to style the .button, as we could apply .is-fullwidth to the button as well?

<div class="dropdown is-fullwidth">
  <div class="dropdown-trigger">
    <button class="button is-fullwidth">
    </button>
  </div>
</div>

BenMorel avatar Sep 21 '18 11:09 BenMorel

I need the same thing. Could you please consider adding this class, to avoid fiddling too much with the CSS? This works fine:

.dropdown.is-fullwidth {
  display: flex;

  .dropdown-trigger,
  .dropdown-menu {
    width: 100%;
  }
}

@andreolaya Do we really need to style the .button, as we could apply .is-fullwidth to the button as well?

<div class="dropdown is-fullwidth">
  <div class="dropdown-trigger">
    <button class="button is-fullwidth">
    </button>
  </div>
</div>

Or less CSS, so you don't need that .is-fullwidth to the button. Plus you can easily control the text align inside the dropdown using .has-text-right etc..

   .dropdown.is-fullwidth {
      display: flex;
   }

   .dropdown.is-fullwidth * {
       width: 100%;
    }
  ......
   <div class="dropdown-trigger">
      <button class="button">
         <span class="has-text-right">Content</span>
   .......                

fadziljusri avatar Nov 14 '18 09:11 fadziljusri

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 13 '19 09:05 stale[bot]

This issue is still relevant.

BenMorel avatar May 14 '19 10:05 BenMorel

I have found a solution, which works for me!! finally

tl;dr add position: static on navbar-item


This is the demo html:

<nav class="navbar ">
  <div class="navbar-brand">
    <a class="navbar-item" href="http://bulma.io">
      <img src="http://bulma.io/images/bulma-logo.png" alt="Bulma: a modern CSS framework based on Flexbox" width="112" height="28">
    </a>
 
    <a class="navbar-item is-hidden-desktop" href="https://github.com/jgthms/bulma" target="_blank">
      <span class="icon" style="color: #333;">
        <i class="fa fa-github"></i>
      </span>
    </a>
 
    <a class="navbar-item is-hidden-desktop" href="https://twitter.com/jgthms" target="_blank">
      <span class="icon" style="color: #55acee;">
        <i class="fa fa-twitter"></i>
      </span>
    </a>
 
    <div class="navbar-burger burger" data-target="navMenubd-example">
      <span></span>
      <span></span>
      <span></span>
    </div>
  </div>
 
  <div id="navMenubd-example" class="navbar-menu">
    <div class="navbar-start">
      <div class="navbar-item has-dropdown is-hoverable">
        <a class="navbar-link  is-active" href="/documentation/overview/start/">
          Docs
        </a>
        <div class="navbar-dropdown ">
          <a class="navbar-item " href="/documentation/overview/start/">
            Overview
          </a>
          <a class="navbar-item " href="http://bulma.io/documentation/modifiers/syntax/">
            Modifiers
          </a>
          <a class="navbar-item " href="http://bulma.io/documentation/columns/basics/">
            Columns
          </a>
          <a class="navbar-item " href="http://bulma.io/documentation/layout/container/">
            Layout
          </a>
          <a class="navbar-item " href="http://bulma.io/documentation/form/general/">
            Form
          </a>
          <a class="navbar-item " href="http://bulma.io/documentation/elements/box/">
            Elements
          </a>
 
          <a class="navbar-item is-active" href="http://bulma.io/documentation/components/breadcrumb/">
              Components
            </a>
 
          <hr class="navbar-divider">
          <div class="navbar-item">
            <div>
              <p class="is-size-6-desktop">
                <strong class="has-text-info">0.5.1</strong>
              </p>
 
              <small>
                  <a class="bd-view-all-versions" href="/versions">View all versions</a>
                </small>
 
            </div>
          </div>
        </div>
      </div>
      <div class="navbar-item has-dropdown is-hoverable is-mega">
        <div class="navbar-link">
          Blog
        </div>
        <div id="blogDropdown" class="navbar-dropdown " data-style="width: 18rem;">
          <div class="container is-fluid">
            <div class="columns">
              <div class="column">
                <h1 class="title is-6 is-mega-menu-title">Sub Menu Title</h1>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
              </div>
              <div class="column">
                <h1 class="title is-6 is-mega-menu-title">Sub Menu Title</h1>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
 
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
                <a class="navbar-item " href="/documentation/overview/start/">
            Overview
          </a>
                <a class="navbar-item " href="http://bulma.io/documentation/modifiers/syntax/">
            Modifiers
          </a>
                <a class="navbar-item " href="http://bulma.io/documentation/columns/basics/">
            Columns
          </a>
              </div>
              <div class="column">
                <h1 class="title is-6 is-mega-menu-title">Sub Menu Title</h1>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
                <a class="navbar-item" href="/2017/08/03/list-of-tags/">
                  <div class="navbar-content">
                    <p>
                      <small class="has-text-info">03 Aug 2017</small>
                    </p>
                    <p>New feature: list of tags</p>
                  </div>
                </a>
 
              </div>
              <div class="column">
                <h1 class="title is-6 is-mega-menu-title">Sub Menu Title</h1>
                <a class="navbar-item " href="/documentation/overview/start/">
            Overview
          </a>
                <a class="navbar-item " href="http://bulma.io/documentation/modifiers/syntax/">
            Modifiers
          </a>
                <a class="navbar-item " href="http://bulma.io/documentation/columns/basics/">
            Columns
          </a>
                <a class="navbar-item " href="http://bulma.io/documentation/layout/container/">
            Layout
          </a>
              </div>
            </div>
          </div>
 
          <hr class="navbar-divider">
          <div class="navbar-item">
            <div class="navbar-content">
              <div class="level is-mobile">
                <div class="level-left">
                  <div class="level-item">
                    <strong>Stay up to date!</strong>
                  </div>
                </div>
                <div class="level-right">
                  <div class="level-item">
                    <a class="button bd-is-rss is-small" href="http://bulma.io/atom.xml">
                      <span class="icon is-small">
                        <i class="fa fa-rss"></i>
                      </span>
                      <span>Subscribe</span>
                    </a>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="navbar-item has-dropdown is-hoverable">
        <div class="navbar-link">
          More
        </div>
        <div id="moreDropdown" class="navbar-dropdown ">
          <a class="navbar-item " href="http://bulma.io/extensions/">
            <div class="level is-mobile">
              <div class="level-left">
                <div class="level-item">
                  <p>
                    <strong>Extensions</strong>
                    <br>
                    <small>Side projects to enhance Bulma</small>
                  </p>
                </div>
              </div>
              <div class="level-right">
                <div class="level-item">
                  <span class="icon has-text-info">
                    <i class="fa fa-plug"></i>
                  </span>
                </div>
              </div>
            </div>
          </a>
        </div>
      </div>
      <a class="navbar-item " href="http://bulma.io/expo/">
        <span class="bd-emoji">🎨</span>  Expo
      </a>
      <a class="navbar-item " href="http://bulma.io/love/">
        <span class="bd-emoji">❤️</span>  Love
      </a>
    </div>
 
    <div class="navbar-end">
      <a class="navbar-item is-hidden-desktop-only" href="https://github.com/jgthms/bulma" target="_blank">
        <span class="icon" style="color: #333;">
          <i class="fa fa-github"></i>
        </span>
      </a>
      <a class="navbar-item is-hidden-desktop-only" href="https://twitter.com/jgthms" target="_blank">
        <span class="icon" style="color: #55acee;">
          <i class="fa fa-twitter"></i>
        </span>
      </a>
      <div class="navbar-item">
        <div class="field is-grouped">
          <p class="control">
            <a class="bd-tw-button button" data-social-network="Twitter" data-social-action="tweet" data-social-target="http://bulma.io" target="_blank" href="https://twitter.com/intent/tweet?text=Bulma: a modern CSS framework based on Flexbox&hashtags=bulmaio&url=http://bulma.io&via=jgthms">
              <span class="icon">
    <i class="fa fa-twitter"></i>
  </span>
              <span>
    Tweet
  </span>
            </a>
 
          </p>
          <p class="control">
            <a class="button is-primary" href="https://github.com/jgthms/bulma/archive/0.5.1.zip">
              <span class="icon">
                <i class="fa fa-download"></i>
              </span>
              <span>Download</span>
            </a>
          </p>
        </div>
      </div>
    </div>
  </div>
</nav>
<section class="hero is-primary">
  <div class="hero-body">
    <div class="container">
      <h1 class="title">
        Bulma.io  with Full Width Menu (Mega Menu)
      </h1>
      <h2 class="subtitle">
        Hover over Blog
      </h2>
    </div>
  </div>
</section>

css:

.navbar-item.is-mega {
  position: static;
}
.navbar-item.is-mega .is-mega-menu-title {
  margin-bottom: 0;
  padding: .375rem 1rem;
}

js (optional)

document.addEventListener('DOMContentLoaded', function () {
 
  // Get all "navbar-burger" elements
  var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
 
  // Check if there are any nav burgers
  if ($navbarBurgers.length > 0) {
 
    // Add a click event on each of them
    $navbarBurgers.forEach(function ($el) {
      $el.addEventListener('click', function () {
 
        // Get the target from the "data-target" attribute
        var target = $el.dataset.target;
        var $target = document.getElementById(target);
 
        // Toggle the class on both the "navbar-burger" and the "navbar-menu"
        $el.classList.toggle('is-active');
        $target.classList.toggle('is-active');
 
      });
    });
  }
 
});

Again, position: static is the point

0xouzm avatar Sep 20 '19 12:09 0xouzm

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 18 '20 13:03 stale[bot]

Still relevant.

BenMorel avatar Mar 18 '20 13:03 BenMorel

still relevant to me :(

melizeche avatar Apr 08 '20 07:04 melizeche

I would love this feature.....

eugenedm avatar Jun 25 '20 09:06 eugenedm

I would love this feature, too, it's good to define the full-width of a dropdown. We can always fix by adding custom CSS.

But I selected Bulma, and main reason is not to add custom CSS, and auto support for Responsiveness, by adding custom css, it defeats the purpose.

image

cbmgit avatar Sep 21 '20 09:09 cbmgit

Would love if this is added too.

kasperkamperman avatar Jul 09 '21 09:07 kasperkamperman

Still relevant.

themagicalmammal avatar Feb 17 '23 12:02 themagicalmammal

A comment to prevent stale-bot and to mention that this would help me too 😄

rdehuyss avatar Jun 30 '23 07:06 rdehuyss

Still relevant.

Mako-L avatar Jul 04 '23 12:07 Mako-L

Adding my upvote comment here too

jorvis avatar Jan 01 '24 17:01 jorvis