zoukankan      html  css  js  c++  java
  • View and Data API Tips: Constrain Viewer Within a div Container

    By Daniel Du

    When working with View and Data API, you probably want to contain viewer into a <div> tag, the position and size of <div> can be defined with CSS. The HTML can be simple as below, a <div> tag as a container, the position and style is defined in a CSS class named as “viewer”:

        <h2>Autodesk View and Data API</h2>
        <div id="viewer" class="viewer">
    
        </div>

    For example, here is my css class, make the viewer container with 800px * 500px, and to make it easy to see, I also add a background color:

    .viewer {
    
        background-color: darksalmon;
        height: 500px;
         800px;
      }

    Here is how it looks like, seems good:

    Screen Shot 2016-01-31 at 2.29.30 PM

    Now let’s add viewer, the code snippet is simple, you can go to github for complete code:

            var viewerContainer = document.getElementById(containerId);
            var viewer = new Autodesk.Viewing.Private.GuiViewer3D(
                viewerContainer);

    But just with this style, the viewer is “overflow” out of the <div> container,:

    Screen Shot 2016-01-31 at 2.39.12 PM

    Here is a tip to contains the viewer into the <div> container, just edit the CSS as below, add “position : relative” :

    .viewer {
    
        background-color: darksalmon;
        height: 500px;
         800px;
        position: relative;
    }

    Here is how it looks after the change, the viewer is constrained within the div tag:

    Screen Shot 2016-01-31 at 2.43.25 PM

    Not a big deal, just a small tip in case you do not know.

  • 相关阅读:
    【Java】-NO.16.EBook.4.Java.1.012-【疯狂Java讲义第3版 李刚】- Swing
    【MySQL】-NO.21.MySQL.1.MySQL.1.001-【Install MySQL5.7 On Windows】
    【Java】-NO.17.EBook.4.Java.1.014-【疯狂Java讲义第3版 李刚】- Annotation
    【Java】-NO.20.Exam.1.Java.1.001- 【1z0-807】- OCEA
    【Java】-NO.16.EBook.4.Java.1.005-【疯狂Java讲义第3版 李刚】- 枚举
    【Java】-NO.16.EBook.4.Java.1.006-【疯狂Java讲义第3版 李刚】- 垃圾回收
    【Java】-NO.16.EBook.4.Java.1.008-【疯狂Java讲义第3版 李刚】- 集合/容器
    【Java】-NO.16.EBook.4.Java.1.009-【疯狂Java讲义第3版 李刚】- 泛型
    【Java】-NO.16.EBook.4.Java.1.010-【疯狂Java讲义第3版 李刚】- 异常
    【Java】-NO.16.EBook.4.Java.1.001-【疯狂Java讲义第3版 李刚】- UML
  • 原文地址:https://www.cnblogs.com/junqilian/p/5173316.html
Copyright © 2011-2022 走看看