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;
    width: 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;
    width: 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.

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。



本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/p/5173316.html ,如需转载请自行联系原作者
相关文章
|
Java API Spring
Spring Data Solr的api demo测试操作
Spring Data Solr的api demo测试操作
161 0
Spring Data Solr的api demo测试操作
|
SQL 存储 缓存
深入解析 RDS Serverless 之 Data API
RDS Serverless Data API 已发布
深入解析 RDS Serverless 之 Data API
|
Java 数据库连接 API
Spring Data开发手册|Java持久化API(JPA)需要了解到什么程度呢?
JPA,Java Persistence API是Sun官方提出的Java持久化规范。它为Java开发人员提供了一种对象/关联映射工具来管理Java应用中的关系数据。它的出现主要是为了简...
511 0
|
Web App开发 API 开发者
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
140 0
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
|
Web App开发 API 开发者
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
SAP 电商云 Spartacus UI 同 SAP Customer Data Cloud 集成运行时的 api
|
.NET API 开发框架
从零开始学习 asp.net core 2.1 web api 后端api基础框架(三)-创建Data Transfer Object
原文:从零开始学习 asp.net core 2.1 web api 后端api基础框架(三)-创建Data Transfer Object 版权声明:本文为博主原创文章,未经博主允许不得转载。
1120 0