html - 如何使用设计系统声明基于屏幕的高度?

标签 html css height percentage visualforce

我找到了 Grid 的列嵌套,这样我就可以制作如下 View :

(资源:https://www.lightningdesignsystem.com/utilities/grid/#Column-Nesting)

enter image description here

但是我有一个问题。

当我设置高度单位为“px”时,我可以在div上应用高度。表格的列和行应用高度单位为“百分比”

另一方面,当我将高度单位设置为“百分比”时,我无法在div、列、行和表格上应用高度单位为“百分比”的高度!

我想创建一个基于屏幕的响应式 visualforce 页面。

如何以“百分比”应用高度?

我的代码如下:

<apex:page showHeader="false" standardStylesheets="false"
    sidebar="false" applyHtmlTag="false" applyBodyTag="false"
    docType="html-5.0">
    <html xmlns="http://www.w3.org/2000/svg"
        xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Condition of Operating Room of Mods Clinic</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Import the Design System style sheet -->
<apex:slds />
<style>
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

.operating {
    height: 750px;
    background-color: blue;
}

.logoAndExplaination {
    height: 150px;
    background-color: green; 
}

.nonOperating {
    height: 600px;
    background-color: orange;
}

.waiting{
    margin-top: 0;
    margin-bottom: 0;
    height: 300px;
    background-color: fuchsia;
}

.end {
    margin-top: 0;
    height: 300px;
    background-color: silver;
}

table {
    border-collapse: collapse;
    margin: 2.5px;
}

th {
    border: 1px solid black;
}

td {
    border: 1px solid black;
}
</style>
</head>
<body>
    <!-- REQUIRED SLDS WRAPPER -->
    <div class="slds-scope">
        <!-- PRIMARY CONTENT WRAPPER -->
        <div class="slds-grid slds-wrap">
            <div class="operating slds-col slds-size_2-of-3">
                <table style="width: 99%; height: 99%;">
                    <colgroup>
                        <col width="25%" />
                        <col width="25%" />
                        <col width="25%" />
                        <col width="" />
                    </colgroup>
                    <tr style="height: 5%;">
                        <th>501호</th>
                        <th>502호</th>
                        <th>503호</th>
                        <th>504호</th>
                    </tr>
                    <tr style="height: 28.3%;">
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr style="height: 5%;">
                        <th>101호</th>
                        <th>102호</th>
                        <th>103호</th>
                        <th>104호</th>
                    </tr>
                    <tr style="height: 28.3%;">
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr style="height: 5%;">
                        <th>수술실 1</th>
                        <th>수술실 2</th>
                        <th>수술실 3</th>
                        <th>레이저실(107호)</th>
                    </tr>
                    <tr style="height: 28.3%;">
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </table>
            </div>
            <div class="slds-col slds-size_1-of-3">
                <div class="slds-grid slds-wrap">
                    <div class="logoAndExplaination slds-col slds-size_1-of-1" align="center">
                        <img alt="Image"
                            src=""
                            style="width: 90%;" />
                        <h1 style="color: white; margin: 0; padding: 0; margin-bottom: 5px">상 황 판</h1>
                    </div>
                    <div class="nonOperating slds-col slds-size_3-of-4">
                        <table style="width: 99%; height: 98%;">
                            <colgroup>
                                <col width="33%" />
                                <col width="33%" />
                                <col width="" />
                            </colgroup>
                            <tr style="height: 7.5%;">
                                <th>메디짐 운동실</th>
                                <th>메디짐 치료실</th>
                                <th>회복실1(105호)</th>
                            </tr>
                            <tr style="height: 25.83%;">
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr style="height: 7.5%;">
                                <th>상담실1</th>
                                <th>상담실2</th>
                                <th>회복실2(107호)</th>
                            </tr>
                            <tr style="height: 25.83%;">
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr style="height: 7.5%;">
                                <th>상담실3</th>
                                <th>상담실4</th>
                                <th>미팅룸</th>
                            </tr>
                            <tr style="height: 25.83%;">
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                        </table>
                    </div>
                    <div class="slds-col slds-size_1-of-4">
                        <div class="waiting slds-col slds-size_1-of-1">
                            <table style="width: 98%; height: 99%;">
                                <tr style="height: 15%;">
                                    <th>대기자</th>
                                </tr>
                                <tr style="height: 85%;">
                                    <td></td>
                                </tr>
                            </table>
                        </div>
                        <div class="end slds-col slds-size_1-of-1">
                            <table style="width: 98%; height: 96%;">
                                <tr style="height: 15%;">
                                    <th>시술마침</th>
                                </tr>
                                <tr style="height: 85%;">
                                    <td></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- / PRIMARY CONTENT WRAPPER -->
    </div>
    <!-- / REQUIRED SLDS WRAPPER -->
    <!-- JAVASCRIPT -->
    <!-- / JAVASCRIPT -->
</body>
</html>
</apex:page>

最佳答案

/************** ipad 旋转 ***************/

@media(最大宽度:1080 像素){}

/************** iPad ***************/

@media only screen and (min-width:768px) and (max-width: 1024px) and (orientation: portrait){}

/************** iphone 旋转***************/

@media(最大宽度:767 像素){}

/************** 苹果手机 ***************/

@media(最大宽度:479 像素){}

您必须使用上述条件根据设备宽度设置样式,如果您对样式仍有疑问,请告诉我....谢谢

关于html - 如何使用设计系统声明基于屏幕的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53665061/

相关文章:

javascript - 如何使用 JQuery 处理对 id 以特定字符串开头的链接的点击?

html - 是什么给我的导航栏分配了相等的顶部和底部边距?

jQuery 高度调整

html - 带有 HTML Canvas 的可点击线条和圆圈

java - 使用 Java 将基于表格的布局转换为 div

php - 滚动留言板,如何链接到 div 中的 div 中的 id?

javascript - 灯箱效果(使用最少的 javascript)问题

css - body 文档的 100% 高度

html - 将 div 扩展到页面底部

html - 如果在 asp.net 中改变方向,我可以调用另一个 css 文件吗