我希望根据窗口大小制作表格横幅/标题响应大小。布局显示了我希望如何保持横幅/标题的设计,即使它们每次调整窗口时都会重新调整大小。 这就是布局看起来的样子:
或相同的布局设计刚刚调整了窗口
这是我到目前为止的代码:
<div class="table-responsive">
<table border="0" width="100%" height=60 cellpadding="0" cellspacing="0" class="table table-condenseď">
<tr>
<td width="200">
<a href="http://www.example.com" target=_blank>
<img src="img1.png" width="200" height="100" >
</a>
</td>
<td width="15" height="38" >
<img src="img2.png" width="39" height="33" >
</td>
<td width="100" style="color:white; font-weight: bold; color:blue;">
<font size="3"></font>
<font size="5">
<?php echo $_SESSION['login']; ?>
</font>
</td>
<td width="600" height="45" >
<img src="img3.PNG" width="900" height="100" >
</td>
<td width="100" height="45" >
<ul>
<font color="blue" size="2">
<?php echo date(" d F Y ",time());?>
</font>
<li >
<a href="logout.php">Logout</a>
</li>
</ul>
</td>
</tr>
</table>
</div>
我已经尝试过这段代码,但是我将所有图片都以原始尺寸显示,并且所有图片都在一个小窗口中堆叠在一起。
<div class="row">
<div class="col-sm-3">
<img src="img1.png" >
</a>
</div>
<div class="col-sm-1">
<img src="img2.png" >
</div>
<div class="col-sm-2">
<font size="3"></font>
<font size="5">
<?php echo $_SESSION['login']; ?>
</font>
</div>
<div class="col-sm-4">
<img src="img3.PNG" >
</div>
<div class="col-sm-2">
<ul>
<font color="blue" size="2">
<?php echo date(" d F Y ",time());?>
</font>
<li >
<a href="logout.php">Logout</a>
</li>
</ul>
</div>
</div>
答案 0 :(得分:1)
您可以使用以下网格
执行此操作
.col-xs-1, .col-xs-2, .col-xs-5{
border:1px solid #000;
border-left:none;
height:70px;
}
.test:first-child {
border-left:1px solid #000;
}
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid" style="margin:12px;">
<div class="row test">
<div class="col-xs-2"></div>
<div class="col-xs-2"></div>
<div class="col-xs-1"></div>
<div class="col-xs-5"></div>
<div class="col-xs-2"></div>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
请不要为td定义自定义宽度
.table-responsive类创建一个响应表,它将在小型设备上水平滚动(768px以下)。
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Table</h2>
<p>my Table</p>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>City</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>Stuart</td>
<td>47</td>
<td>Sydney</td>
<td>Australia</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
答案 2 :(得分:0)
您似乎正确地遵循了Bootstrap responsive tables上的文档。我不确定你的问题是什么。如果您正在寻找能够更流畅地移动的列,您可以考虑去掉宽度属性。
如果您希望创建一个传统意义上的响应式布局,其中元素会针对越来越小的视图进行折叠,那么Bootstrap会使用现有的导航栏documentation。在90年代,表格在布局和布局方面很受欢迎,但div是块中的新手,特别是在响应式布局方面。以下是他们的文档中的示例:
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>