To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Framework structure
Cancel

The CSS and HTML Secrets of DataFlex WebApps

Lesson 3 - CSS Sizing and Positioning

A summary of the video course

Before we dive into how the concepts, discussed in previous lessons, are applied within the framework, let's explore some key aspects of CSS related to sizing and positioning. These concepts are essential for understanding how elements are laid out on a web page.

The Box Model

HTML elements can be thought of as boxes with distinct areas:

  • Content Area: Where the actual content of the element resides, such as text or other elements.
  • Padding: Surrounding the content, creating whitespace between the content and the border.
  • Border: A boundary around the content and padding, which can have its own size.
  • Margin: The space between different elements, affecting their positioning in relation to each other.

Impact on Width and Height 

When you set the width or height of an element (e.g., width: 20px), you're specifying the dimensions of the content area. However, keep in mind that the element's total size is influenced by padding, border, and margin. So, it occupies more space than just the specified dimensions.

Box Sizing Property

The box-sizing property determines how an element's width and height are calculated. By default, it's set to content-box, which calculates dimensions based on the content area only. However, you can change it to border-box, where the specified width includes both the border and padding.

For instance, if you set a width of 20px on an element with a 1px border and 2px padding, the total width will be less than 20 pixels if box-sizing is set to border-box.

The Position Attribute

The position attribute controls how an element positions itself within the layout. Several values are available:

  • Static (Default): The element participates in the normal flow of the page, and the top, left, bottom, and right attributes have no effect.
  • Relative: Similar to static positioning but allows you to use top, left, bottom, and right to offset the element from its normal position.
  • Fixed: Removes the element from the flow, positioning it relative to the viewport, and it doesn't scroll with the page.
  • Absolute: Positions the element relative to its nearest positioned ancestor, often used with position: relative on the parent element.

Examples of Positioning 

Illustrative examples help understand how positioning works:

  • position: fixed; bottom: 10px; right: 10px; fixes an element to the bottom-right corner of the viewport.
  • position: absolute; top: 60px; left: 250px; positions an element 50 pixels from the left and 60 pixels from the top of its nearest positioned ancestor.

The Display Attribute

The display attribute determines how an element is rendered in the layout. Common values include:

  • none: Hides the element completely and doesn't occupy any space.
  • block: Renders the element as a block-level element, taking up the full width of its parent.
  • inline: Makes the element part of the text flow, allowing other elements to appear on the same line.

Understanding Float 

The float property allows elements to float left or right within their parent container, affecting their positioning. The clear property ensures that no elements float next to a floated element.

Interactive CSS Editing

You can experiment with CSS in developer tools, enabling you to make real-time style changes and visualize their effects on the page. However, these changes are temporary and should be copied to your actual stylesheet if desired.

With a solid grasp of these CSS sizing and positioning concepts, you're better prepared to understand how they are utilized within the framework's structure. In our next lesson, we'll explore the framework's architecture and see how these concepts come together to build web applications. Stay tuned!