Im having an issue with a dropdown menu within a responsive table in Bootstrap 3. No matter what I place in the CSS (like overflow: auto or positioning) the menu in the dropdown appears within the responsive div and in order to click on any of the links you would have to scroll.
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr class="table_desc">
<th></th>
<th><input type="checkbox"></th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="table_items">
<td><div class="item_strip"></div></td>
<th><input type="checkbox"></th>
<td>Deposit Paid</td>
<td>
<!-- Split button -->
<div class="btn-group action-button">
<button type="button" class="btn btn-xs btn-danger">View</button>
<button type="button" class="btn btn-danger btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Edit</li>
<!-- <li class="divider"></li> -->
<li>Send Invoice</li>
<li>Send Reminder</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Any Ideas?
after debugging in bootstrap.css on line 2247
#media screen and (max-width: 767px) {
.table-responsive {
width: 100%;
margin-bottom: 15px;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #ddd;
}
If you comment both overflows it works properly.It doesn't work properly below width 767 because of the overflow properties if you simply overwrite those in your css it will work.
Related
I have a problem with the positioning (?) of my div boxes. I have a div box for my navigation bar.
I want a div box right under the navigation bar in the center, which can be filled with some text.
I tried:
.navigation {
background-color: black;
position: fixed;
width: 1920px;
left: 0px;
top: 0px;
}
.inhalt {
position: realative;
margin: 0px auto;
width: 600px;
top: 600px;
background-color: white;
}
<div class="navigation">
<table>
<tr>
<th><img src="logo.jpeg"></th>
<th></th>
<th></th>
<th>Startseite</th>
<th>Beats</th>
<th>Preise</th>
<th>Kontakt</th>
</tr>
</table>
</div>
Thanks for any answer!!
1- first, .inhalt class position must be "relative" not "position:realative;" as you have written above so the "top" property could work.
2- give height to your second box so you can see it.
3- When elements are positioned, they can overlap other elements. you can solve this by either give your navigation bar "sticky" position or if you want to use fixed position, use "top" property to solve the problem. I add a snippet for this solution.
4- you can use first give your navigation bar relative position and then on scrolling give it a fixed position. see the example on codepen.
.navigation{
background-color: black;
position: fixed;
width: 100%;
left: 0px;
top: 0px;
z-index: 99999;
}
.inhalt{
position:relative;
width: 600px;
height: 500px;
top: 30px;
margin: 0px auto;
background-color: lightblue;
}
<div class="navigation">
<table>
<tr>
<th><img src="logo.jpeg"></th>
<th></th>
<th></th>
<th>Startseite</th>
<th>Beats</th>
<th>Preise</th>
<th>Kontakt</th>
</tr>
</table>
</table>
</div>
<div class="inhalt"></div>
Your question is vague, but this should give you some idea to work with:
.navigation {
background-color: black;
float: left;
position: fixed;
width: 1920px;
left: 0px;
top: 0px;
float: left
}
.inhalt {
float: left;
text-align: center;
top: 15%;
left: 10%;
margin: 0px auto;
width: 100%;
background-color: white;
font-size: 20px;
}
<div id="wrapper">
<div class="navigation">
<table>
<tr>
<th><img src="logo.jpeg"></th>
<th></th>
<th></th>
<th>Startseite</th>
<th>Beats</th>
<th>Preise</th>
<th>Kontakt</th>
</tr>
</table>
</div>
<div class="inhalt">
<p> Some random Text </p>
</div>
</div>
Also you should prefer using lists <li> for your navigation, since tables can be a nightmare to work with in that particular usecase.
Ok so in addition to what explained Phanti, your HTML has an issue as there are two times the closing tab
That would be my CSS I removed some of the instructions that were not making sense to me like the fix width:
.navigation {
background-color: black;
float: left;
position: fixed;
width: 100%;
height:40px;
left: 0px;
top: 0px;
float: left
}
.inhalt {
float: left;
text-align: center;
margin-top: 60px;
margin: 0px auto;
width: 100%;
background-color: white;
font-size: 20px;
}
That would be my HTML :
<div id="wrapper">
<div class="navigation">
<table>
<tr>
<th><img src="logo.jpeg"></th>
<th></th>
<th></th>
<th>Startseite</th>
<th>Beats</th>
<th>Preise</th>
<th>Kontakt</th>
</tr>
</table>
</div>
<div class="inhalt">
<p> Some random Text </p>
</div>
</div>
Overall, since you seem to be starting on html and CSS, I would storngly advise you to start with a CSS Framwork like bootstrap, you will be able to easily build from scratch responsive website by relying on predefined classes and module (especially for menu where moving from desktop to tablet to mobile is very painful).
If you were to use Bootstrap 4 here would be a code working on all support :
Insert this between your :
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
Then add this in your code for the navigation and your content
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</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="#" tabindex="-1" aria-disabled="true">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>
<div class="container">
<div class="row">
<div class="col-md-12">
<p>Some content</p>
</div>
</div>
</div>
<!-- HTML -->
div class="inhalt">
<p> some text </p>
</div>
/*-- CSS-- */
.inhalt{
margin: 10px auto 0;
width: 50%;
}
This is the perfect way of centring the div element.
I am trying to open action div box as layer in but unable to do that.
when i click on action button div box will open within that only. it should be open as layer.
Code:
ul {
z-index: 2
}
table {
z-index: 1
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Sr.No</th>
<th>LeadCreated DateTime</th>
<th>RetailerName</th>
<th>ShopName</th>
<th>Mobile</th>
<th>Address</th>
<th>City</th>
<th>Pincode</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>1</td>
<td>10-10-2017</td>
<td>Test</td>
<td>Test</td>
<td>9904773479</td>
<td>Surat</td>
<td>Surat</td>
<td>304230</td>
<td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
<?= $row->Status ?>
</td>
<td class="pbutton">
<div class="btn-group">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right " role="menu" style="position: relative;width: 160px;z-index: 99">
<li><span class="glyphicon glyphicon-fullscreen"></span> View</li>
<li><span class="fa fa-edit"></span> Add Lead Update</li>
<li><span class="fa fa-edit"></span> Edit</li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
Make the .btn-group positioned relative and the ul positioned absolute. You may want to change the absolute positioning according to your liking.
The z-index can be removed.
.btn-group {
position: relative;
}
ul.dropdown-menu.pull-right {
position: absolute;
top: 0;
left: -160px;
width: 160px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Sr.No</th>
<th>LeadCreated DateTime</th>
<th>RetailerName</th>
<th>ShopName</th>
<th>Mobile</th>
<th>Address</th>
<th>City</th>
<th>Pincode</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>1</td>
<td>10-10-2017</td>
<td>Test</td>
<td>Test</td>
<td>9904773479</td>
<td>Surat</td>
<td>Surat</td>
<td>304230</td>
<td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
<?= $row->Status ?>
</td>
<td class="pbutton">
<div class="btn-group">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right " role="menu">
<li><span class="glyphicon glyphicon-fullscreen"></span> View</li>
<li><span class="fa fa-edit"></span> Add Lead Update</li>
<li><span class="fa fa-edit"></span> Edit</li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
Try this
ul.dropdown-menu{
position:absolute !important;
}
or use inline styles
<ul class="dropdown-menu pull-right " role="menu" style="position: absolute;width: 160px;z-index: 99">
Override the ul.dropdown-menu styles to make it absolute, either use !important or override the inline styles.
ul.dropdown-menu{
position: absolute !important;
width: 200px;
top: 15%;
left: 20%;
}
ul.dropdown-menu {
z-index: 2
}
table {
z-index: 1
position: relative;
}
ul.dropdown-menu{
position: absolute !important;
width: 200px;
top: 15%;
left: 20%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Sr.No</th>
<th>LeadCreated DateTime</th>
<th>RetailerName</th>
<th>ShopName</th>
<th>Mobile</th>
<th>Address</th>
<th>City</th>
<th>Pincode</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>1</td>
<td>10-10-2017</td>
<td>Test</td>
<td>Test</td>
<td>9904773479</td>
<td>Surat</td>
<td>Surat</td>
<td>304230</td>
<td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
<?= $row->Status ?>
</td>
<td class="pbutton">
<div class="btn-group">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right " role="menu" style="position: relative;width: 160px;z-index: 99">
<li><span class="glyphicon glyphicon-fullscreen"></span> View</li>
<li><span class="fa fa-edit"></span> Add Lead Update</li>
<li><span class="fa fa-edit"></span> Edit</li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
i have the following html
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<tr>
<td class="text-center">
<button type="button" data-toggle="dropdown" class="btn btn-warning dropdown-toggle" aria-expanded="false">
<i class="fa fa-phone" aria-hidden="true"></i>
<div style="background-color:white;width:0.5em;display:inline-block;"></div>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right"> <li><i class="fa fa-eye"></i> Vizualizeaza</li>
<li><i class="fa fa-plus"></i> Adauga</li>
</ul>
</td>
</tr>
what i'm trying to do is to make a dropdown, but i have two problems, first one, the div in the middle of the button won't display (i need to make a white delimitation, i don't know if this is the right way i'm trying)
and second, this html it inside a loop and when i click the button, the dropdown opens at the end of the table
You need to add dropdown class for making the dropdown to work as follows
<tr>
<td class="text-center">
<div class="dropdown">
<button type="button" data-toggle="dropdown" class="btn btn-warning dropdown-toggle" aria-expanded="false">
<i class="fa fa-phone" aria-hidden="true"></i>
<div style="background-color:white;width:0.5em;display:inline-block;"></div>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><i class="fa fa-eye"></i> Vizualizeaza</li>
<li><i class="fa fa-plus"></i> Adauga</li>
</ul>
</div>
</td>
</tr>
And for making the div visible specify height property as well
<div style="background-color:white;width:0.5em;display:inline-block;"></div>
Hope this works
I think I have an idea of what you're trying to accomplish. All of the code to do this can be found on bootstrap's website. That link will direct you to how to create dropdown buttons in bootstrap 3. Additionally, here's a link to a codeply project with the code in action.
<tr>
<td>
<div class="btn-group">
<button type="button" class="btn btn-warning"><i class="fa fa-phone"></i></button>
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><i class="fa fa-eye"></i> Vizualizeaza</li>
<li><i class="fa fa-plus"></i> Adauga</li>
</ul>
</div>
</td>
</tr>
WORKING EXAMPLE ! Please wrap Button and ul inside a div."'div class="btn-group">'", This should resolve your problem.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Basic Table</h2>
<p>The .table class adds basic styling (light padding and only horizontal dividers) to a table:</p>
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<tr>
<td class="text-center">
<div class="btn-group">
<button type="button" data-toggle="dropdown" class="btn btn-warning dropdown-toggle" aria-expanded="false">
<i class="fa fa-phone" aria-hidden="true">Button click</i>
<div style="background-color:white;width:0.5em;display:inline-block;"></div>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu"><li><i class="fa fa-eye"></i> Vizualizeaza</li>
<li><i class="fa fa-plus"></i> Adauga</li>
</ul>
</div>
</td>
</tr>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Basically, You should wrap button and ul inside a div with below properties.
position: relative;
display: inline-block;
vertical-align: middle;
Or you can use bootstrap class "btn-group"
I am using jasny-bootstrap's navmenu along with a navbar both of which have their own toggle buttons which will collapse them.The view works very nicely on mobile views but the navbar items render oddly when preseneted in a desktop or a tablet view.
This is a jsfiddle that has my code.
This is the CSS:
html, body {
height: 100%;
}
body {
padding-top:60px;
}
.navbar-toggle {
float: left;
margin-left: 15px;
}
a.navbar-toggle {
float: right;
margin-right: 15px;
}
.navmenu {
z-index: 1;
}
.canvas {
position: relative;
left: 0;
z-index: 2;
min-height: 100%;
padding: 50px 0 0 0;
background: #fff;
}
#media (min-width: 0) {
.navbar-toggle-reveal {
display: block;
/* force showing the toggle */
}
}
#media (min-width: 992px) {
body {
padding: 0;
}
.navbar {
right: auto;
background: none;
border: none;
}
.canvas {
padding: 0;
}
}
This is the markup:
<div class="navmenu navmenu-default navmenu-fixed-left"> <a class="navmenu-brand" href="#">Project name</a>
<div class="nav navmenu-nav">
<table class="table table-responsive table-hover table-striped table-bordered">
<tbody>
<tr>
<td>DESCRIPT</td>
<td>This is a description</td>
</tr>
<tr>
<td>EQUICATGRY</td>
<td>M</td>
</tr>
<tr>
<td>PLANGROUP</td>
<td>010</td>
</tr>
<tr>
<td>PLANPLANT</td>
<td>0001</td>
</tr>
<tr>
<td>OBJECTTYPE</td>
<td>001</td>
</tr>
<tr>
<td>AUTHGRP</td>
<td>3000</td>
</tr>
</tbody>
</table>
</div>
<ul class="nav navmenu-nav">
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
<li class="dropdown"> Dropdown <b class="caret"></b>
<ul class="dropdown-menu navmenu-nav">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
</ul>
</div>
<div class="canvas">
<div class="navbar navbar-default navbar-fixed-top navbar-pills">
<button type="button" class="navbar-toggle navbar-toggle-reveal" data-toggle="offcanvas" data-recalc="false" data-target=".navmenu" data-canvas=".canvas"> <span class="glyphicon glyphicon-chevron-right"></span>
<span class="glyphicon glyphicon-chevron-right"></span>
</button>
<div class="navbar-header">
<!--navbar-toggle is not hidden when not in lg,md,xs grid,it is visible on the far-left rather than on the far-right --> <a href="#" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="navbar-brand" href="#">Fargo</a>
</div>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-nav navbar-left">
<li>Left Home
</li>
<li>Left Work
</li>
<li>Left Mobile
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Home
</li>
<li>Work
</li>
<li>Mobile
</li>
</ul>
</div>
</div>
<div class="container">
<p class="lead">This example demonstrates the use of the offcanvas plugin with a reveal effect.</p>
<p>On the contrary of the push effect, the menu doesn't move with the canvas.</p>
<p>You get the reveal effect by wrapping the content in a div and setting the <code>canvas</code> option to target that div.</p>
<p>Note that in this example, the navmenu doesn't have the <code>offcanvas</code> class, but is placed under the canvas by setting the <code>z-index</code>.</p>
<p>Also take a look at the examples for a navmenu with slide in effect and push effect.</p>
</div>
<!-- /.container -->
</div>
I'm not sure how exactly you want it to look (what does "render oddly" mean? How should it render?) but I'm fairly certain it's the entire last media query that is giving you trouble:
#media (min-width: 992px) {
body {
padding: 0;
}
.navbar {
right: auto;
background: none;
border: none;
}
.canvas {
padding: 0;
}
}
This block says that for any screen size above 992px wide a couple of styles change that are definitely making your navbar look strange compared to the smaller screen view. Remove that block and see if it solves your problem.
I have a navbar on the top of my html site. I recently wanted to change it so that the bar will always show on the page as the user scrolls down. I ran into a problem when doing this. For some reason, it takes the list and stacks it vertically when initially it is horizontally. I have been trying to find a solution for this but I am stuck. Here is what it looks like:
I can not figure out how to keep the list horizontal, All help is greatly appreciated!
<table>
<!-- first row -->
<tr>
<!-- first column -->
<td colspan="2" style="position: fixed; top: 0px; right: 50%">
<div class="navbar" style="text-align: center; margin: 0 auto;">
<div class="navbar-inner">
<div class="brand">
<a href="www.investorsfortunes.com">
Investorsfortunes.com
</a>
</div>
<ul class="nav">
<li class="divider-vertical">Investors</li>
<li class="divider-vertical">Deals</li>
<li class="divider-vertical">Attornies</li>
<li class="divider-vertical">Appraisers</li>
<li class="divider-vertical">Contact Us</li>
<li class="login">
<button class="btn btn-primary" id="loginBtn" >Login</button>
</li>
<li class="login">
<button class="btn btn-primary" id="loginBtn" >Sign-Up</button>
</li>
</ul>
</div>
</div>
</td>
<!-- second column -->
<td>
</td>
<!-- third column -->
<td>
</td>
</tr>
</table>
wrap your nav bar in between these div elements
<div id="navbar" class="navbar navbar-fixed-top ">
</div>