【问题标题】:I am trying to make the second bootstrap row fill the remaining height我正在尝试使第二个引导行填充剩余的高度
【发布时间】:2016-07-05 18:49:04
【问题描述】:

我正在构建一个连接到 SQL 数据库的 ASP.NET 应用程序。这是一个屏幕截图:

我想要:

1) 我的图表占用所有空白空间(即第二行高度)

2) 为图表添加内边距,使右侧的日期完整显示

我不能看到明显的东西。感谢您的帮助!

这是我的代码:

<!DOCTYPE html>

<html>
<head>
  <title></title>
    <link href="css/nv.d3.css" rel="stylesheet" type="text/css">
    <link href="Content/bootstrap.min.css" rel="stylesheet"/>
    <link href="css/pikaday.css" rel="stylesheet" type="text/css" />
    <link href="css/theme.css" rel="stylesheet" type="text/css" />
    <link href="css/site.css" rel="stylesheet" type="text/css" />
    <script src="scripts/Pikaday/moment.js" type="text/javascript"  ></script>
    <script src="scripts/Pikaday/pikaday.js" type="text/javascript"></script>
    <script src="scripts/jquery-1.9.1.js"></script>
    <script src="scripts/d3.min.js" charset="utf-8"></script>
    <script src="scripts/nv.d3.min.js"></script>

<style>
.singleLabel{
    min-height: 20px;
    text-align: left;
    font-size: large;
    margin-bottom:2px;
}
.textBox{
    border-left-width: 1px;
    min-height: 20px;
    text-align: center;
    font-size: large;
    margin-bottom:2px;
}
.textbox.dropDown{
    text-align: right;
}
text {
    font: 12px sans-serif;
}
    html, body, #chart, svg{
    margin: 0px;
    padding: 0px;
    height: 100%
    width: 100%;
}
.nv-x text{
    font-size: 20px;
}
.nv-y text{
    font-size: 20px;
}
.nv-series text {
    font-size: 20px;
}
.row {
    font-size: 30px;
}
.column{

}
</style>
</head>

<body>
   <form id="form1" runat="server">
   <div class="row">&emsp;Report from:&emsp;
   <asp:TextBox ID="startDate" runat="server" columns="6" style="border:1px solid #ff0000"></asp:TextBox>
   &emsp;To&emsp;
   <asp:TextBox ID="endDate" runat="server" columns="6" style="border:1px solid #ff0000"></asp:TextBox>
   &emsp;<input type="button" id="btGO" value="Go!" />


   <%-- Date picker for start and end --%>
   <script = "text/javascript">
      var picker = new Pikaday({
           field: document.getElementById("startDate"),
           firstDay: 1,
           format: "YYYY-MM-DD",
           minDate: new Date('2000-01-01'),
           maxDate: new Date('2020-12-31'),
           yearRange: [2000,2020],
           numberOfMonths: 2
      });
   </script>

    <script = "text/javascript">
      var picker = new Pikaday({
           field: document.getElementById("endDate"),
           firstDay: 1,
           format: "YYYY-MM-DD",
           minDate: new Date('2000-01-01'),
           maxDate: new Date('2020-12-31'),
           yearRange: [2000,2020],
           numberOfMonths: 2
      });
   </script>
</div>
<div class="row">
<div class="col-lg-12">
<div id="chart">
    <svg></svg>
</div>
</div>
</div>
<script>
    d3.json('https://cdn.rawgit.com/novus/nvd3.org/master/ghpages/stackedAreaData.json', function (data) {
        nv.addGraph(function () {
            var chart = nv.models.stackedAreaChart()
                          .x(function (d) { return d[0] })
                          .y(function (d) { return d[1] })
                          .clipEdge(true)
                          .useInteractiveGuideline(true);

            chart.xAxis
                .showMaxMin(true)
                .tickFormat(function (d) { return d3.time.format('%x')(new Date(d)) });

            chart.yAxis
                .tickFormat(d3.format(',.0f'));

            d3.select('#chart svg')
              .datum(data)
                .transition().duration(500).call(chart);

            nv.utils.windowResize(chart.update);

            return chart;
        });
    })
</script>
</form>

</body>
</html>

【问题讨论】:

    标签: javascript css asp.net twitter-bootstrap


    【解决方案1】:

    尝试使用固定值之类的高度。我觉得&lt;div id="chart"&gt;是你要垂直占用空间的图表?

    试试你的 CSS:

    div.chart {
        height: 80vh;
    }
    

    VH 代表视口高度。所以它将占用屏幕高度的 80%。

    对于你可以尝试的行

    padding: 0 10px;
    

    或其他值,只是您喜欢的填充。

    【讨论】:

    • 非常感谢!这正是我所需要的!如此简单优雅!
    【解决方案2】:

    您可以使用 flexbox 完成此操作。

    this fiddle 中的 Flexbox 示例

    关键 CSS:

    #container{
      display: flex;
      flex-direction: column;
    }
    #graph{
      flex-grow: 1;
    }  
    

    让我知道这是否有帮助,或者如果您还有其他问题。您还需要包含前缀,如 here 所示。

    【讨论】:

    • 非常感谢您的帮助! :D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多