BootStrap expand menu to 100% with in its respective column

0

I'm doing a layout boostrap to go getting into the thread, in the first row I want to have: on the left the name of the page, and on the right the menu with its buttons and such.

The problem that has arisen is that the menu that is supposed to be on the left does not reach the end of the row (when you see the code in the browser you will see that there is a space to the right without re-filling with the menu )

        <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title>Maquetado v.1</title>
    
    
    	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    </head>
    
    <body>
    	
    	<div class="container">
    		<div class="row  bg-warning">
    			<!-- tiitutlo -->
    			<div class="col-md-4 col-sm-8 col-xs-4">
                	<h1 class="text-primary text-center " >Menu</h1>
            	</div>
            	<div class="col-md-8 col-sm-4 col-xs-4 ">
            		<!-- menu -->
    				
    				<nav class="navbar navbar-expand-lg navbar-light bg-light">
    	  <a class="navbar-brand" href="#">Menu</a>
    	  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    	    <span class="navbar-toggler-icon"></span>
    	  </button>
    
    	  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    	    <ul class="navbar-nav mr-auto">
    	      <li class="nav-item active">
    	        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
    	      </li>
    	      <li class="nav-item">
    	        <a class="nav-link" href="#">Link</a>
    	      </li>
    	      <li class="nav-item dropdown">
    	        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    	          Dropdown
    	        </a>
    	        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
    	          <a class="dropdown-item" href="#">Action</a>
    	          <a class="dropdown-item" href="#">Another action</a>
    	          <div class="dropdown-divider"></div>
    	          <a class="dropdown-item" href="#">Something else here</a>
    	        </div>
    	      </li>
    	      <li class="nav-item">
    	        <a class="nav-link disabled" href="#">Disabled</a>
    	      </li>
    	    </ul>
    	    <form class="form-inline my-2 my-lg-0">
    	      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
    	      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    	    </form>
    	  </div>
    	</nav>
    <!-- fin menu -->
            	</div>
    		</div>
    		<div class="row ">
    			
    		</div>
    
    		<div class="row">
    			<div class="col-3 bg-info">
    				<p>a</p>
    			</div>
    			<div class="col-6 bg-success">
    				<p>b</p>
    			</div>
    			<div class="col-3 bg-primary">
    				<p>c</p>
    			</div>
    		</div>
    
    	</div>
    
    </body>
    </html>

I've been looking through the web and I have not found what I wanted. Another question that arises is to what extent I should put CSS to the extent that I can not fix my problems with the same bootstrap. Thank you very much in advance.

PS: I want to go documenting my problems with the layout on this. Those experienced in StackOverflow advise me to add new problems to this question? or close this and create a new one for each new problem found even if it is the same layout? Thanks again community

    
asked by josanangel 29.04.2018 в 11:35
source

2 answers

2

I've been looking through the code and the orange part that comes out on the right is not part of the orange menu on the left. Be careful with the div. Apparently you have another and inside him. If you want it to fit 100% of width as indicated, you must use the class .container-fuild. I'll leave the code for you, if that's how you wanted it.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Maquetado v.1</title>


      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    </head>

    <body>

      <div class="container">
        <div class="row  bg-warning">
          <!-- tiitutlo -->
          <div class="col-md-4 col-sm-8 col-xs-4">
            <h1 class="text-primary text-center " >Menu</h1>
          </div>
          
          <!-- menu -->

          <nav class="navbar navbar-expand-lg navbar-light bg-light container-fluid">
            <a class="navbar-brand" href="#">Menu</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
              <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                  <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Link</a>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Dropdown
                  </a>
                  <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Something else here</a>
                  </div>
                </li>
                <li class="nav-item">
                  <a class="nav-link disabled" href="#">Disabled</a>
                </li>
              </ul>
              <form class="form-inline my-2 my-lg-0">
                <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
              </form>
            </div>
          </nav>
          <!-- fin menu -->
          
        </div>
        <div class="row ">

        </div>

        <div class="row">
          <div class="col-3 bg-info">
            <p>a</p>
          </div>
          <div class="col-6 bg-success">
            <p>b</p>
          </div>
          <div class="col-3 bg-primary">
            <p>c</p>
          </div>
        </div>

      </div>

    </body>
    </html>

And my answer to your final question is, use CSS freely whenever you need to give a more personal touch to the web or to a particular element. You should not restrict the use to only bootstrap. In my case, I use the bootstrap to make the template and make it as responsive as possible, and then I apply different styles with different CSS.

Greetings!

    
answered by 29.04.2018 в 12:46
1

Basically as a good framework, Bootstrap makes life easier for us by having already done work for several things, mainly (its most useful in my opinion) for responsive web design. In this case we have 12 column grid, each of equal width (width). So, you must decide (in your prototype), how much to assign to each of the 3 columns (a, b and c) and to "avoid" that you have "air" somewhere, you can for example in the case of the menu that what I see is static (it is not generated by a CMS or script), calculate approximately how many column grid you would need to be as adjusted as possible according to the size of the font, type, etc ... After that, surely (most likely ) is that you also have space to your right (in this case), which you can solve either by centering the menu within the column (b) and / or by managing the padding between menu items in such a way that it "fits" with the column grid that you assigned.

Another detail, "xs" is used to define screen "extra small", that is basically mobile (cellular) so you tend to use 12 of column grid.

PS: I would leave the "search" in a separate column of the menu. The division could be something like a = 2, b = 6 and c = 4 (in col-md and obviously the col-lg).

Regarding each problem, each question if it is a problem different from the one specified in the current question. They are different threads but if it is the same (without leaving the thread) you can go adding them here.

I hope I have helped you.

Cordial Greetings!

    
answered by 29.04.2018 в 12:35