【问题标题】:CSS positioning inside a DIVDIV 内的 CSS 定位
【发布时间】:2014-06-12 17:19:09
【问题描述】:

我已经使用 Position: Absolute 很长时间了,我得出的结论是它没有希望。我希望我的应用程序是一个流畅的布局,因此它可以以不同的分辨率进行缩放。

这就是我想要达到的目标:

我已经成功实现了左侧手边3个日历控件。

中间部分是一个 DayPilot Calender 控件,下面是一个输入,您可以输入我设法实现的注释。

正确的位需要是一个面板,我可以在其中添加标签、下拉菜单和其他内容,以便用户将内容添加到日历中,但我似乎无法将其放在那里。

这是我的 CSS:

#body {
height: 540px;  //This is the body section.
}

#dashboardinformataion { // this is the whole box you can see on the picture
height: 481px;
width: 80%;
margin: 0 auto 0;
display: flexbox;
display: -ms-flexbox;
}

#txt_headernotes { // this is the input for the input saying 'Notes' in image.
width: 100%;
text-align: center;
}

#txt_displayinformation { // this is the input below the notes section.
width: 100%;
height: 12.5%;
}

#middlesection { // this is the DIV wrapping the calender and the 2 input boxes.
height: 481px;
}

#calender_control { //This is in the Middle div above the notes input label.
width: 700px !important;
}

这是 HTML:

        <div id="body">
        <div id="dashboardinformataion">
            <DayPilot:DayPilotNavigator ID="DayPilotNavigator1" runat="server" 
                BoundDayPilotID="calender_control" 
                SelectMode="Month"
                ShowMonths="3"
                SkipMonths="3"


                DataStartField="start"
                DataEndField="end" 
                VisibleRangeChangedHandling="CallBack"
                OnVisibleRangeChanged="DayPilotNavigator1_VisibleRangeChanged"

                >
            </DayPilot:DayPilotNavigator>

            <div id="middlesection">
                <DayPilot:DayPilotMonth CssClassPrefix="bsimplexcalender" OnCommand="calender_control_Command" ContextMenuID="menu" EventRightClickHandling="ContextMenu" EventRightClickJavaScript="select(e)" BubbleID="DayPilotBubble1" ClientObjectName="dpm" runat="server" ID="calender_control" Theme="bsimplexcalender" HeightSpec="Auto" Height="0" MinCellHeight="63" DataStartField="start" DataEndField="end" DataTextField="name" DataValueField="id" OnBeforeEventRender="calender_control_BeforeEventRender" />
                <input runat="server" id="txt_headernotes" placeholder="Notes" />
                <input runat="server" id="txt_displayinformation" />
            </div>

            <asp:Panel ID="Panel1" runat="server" BackColor="Black"></asp:Panel>



       </div>

我的定位是否正确以及如何在右侧获得一个宽度为 140 像素的面板

编辑:我的 CodePen www.codepen.io/anon/pen/snJAc 非常感谢

【问题讨论】:

  • 因为你使用的是 display: flexbox; ...您应该尝试使用它的特殊属性来设置您的布局..您需要考虑 3 列而不是 1 中间列,供参考:css-tricks.com/snippets/css/a-guide-to-flexbox
  • @webkit 我必须有 3 个不同的 DIV 标签吗?这就是为什么它不起作用?我会检查它的 flexbox 属性。
  • 如果你想要一个响应式布局,用与你的草图相同的逻辑标记你的代码更有意义。所以是的,使用 3 个 div,这样更容易控制元素在响应式 css 中的每个容器内。
  • @webkit 我做了 3 个 div,但我仍然看不到我的第三个 div?

标签: html css asp.net


【解决方案1】:
<div id="hold">
width:500px; margin: 0 auto;

<div id="left">
height: 500px;
width:100px;

</div>

<div id="middleHold">
float:left;

<div id="middle1">
height: 250px;
width: 300px;
</div>

<div id="middle2">
height: 50px;
width: 300px;
</div>

<div id="middle3">
height: 200px;
width: 300px;
</div>

</div> <!-- end #middleHold -->

<div id="right">
width: 100px;
height: 500px;
float:left;
</div>

</div> <!-- end #hold -->

这是 id,只需将 css 添加到它们。

【讨论】:

  • 您使用的是 PX?这不意味着它不会扩展吗?
  • 是的,只需将其更改为 %?我建议您使用已经构建的网格系统。 Bootstrap 或 RocketCSS 什么的。
猜你喜欢
  • 2012-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-03
  • 2023-03-12
相关资源
最近更新 更多