Cascading Style Sheets Boxes

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today CSS Properties –Box properties-- List properties –Table properties-- Classification properties –(Audio.
Advertisements

CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Client-Side Internet and Web Programming
More CSS CS HTML id attribute 2 Coding Horror! Our mission is to combine programming and “human” factors with geekiness! output  A unique ID for.
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
Today’s objectives Site performance Padding, Margins, Borders
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
CSS provides a way to stray away from the traditional methods of using tables to lay out pages. Success with this technique depends on understanding of.
Tutorial 4: Creating page layout with css
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
CSS: Class 1 Background Images, Controlling Position of Background Images, Add Padding to Page Elements, Add Borders to Elements on a Page.
An Introduction to Cascading Style Sheets CSS Layout, and the CSS Box Model Nick Foxall SM5312 week 9: CSS Layout.
MORE Cascading Style Sheets (The Positioning Model)
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
Slide 1 of 83 Table Borders To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td.
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
CSS Border.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
LITTLE BOXES Controlling size of boxes Box model for borders, margin and padding Displaying and hiding boxes.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls.
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  CSS Box Model  CSS properties for border  CSS properties for.
Tutorial 4 Creating Page Layouts with CSS
CIS234A Lecture 6 Instructor Greg D’Andrea. Span and Div The span and div elements are a generic means by which we can add structure to documents. The.
CSS Table Styling. Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
CSS.
Laying out Elements with CSS
Cascading Style Sheets Layout
CSS Box Model.
CSS Box Model.
The Box Model in CSS Web Design – Sec 4-8
Cascading Style Sheets™ (CSS)
( Cascading style sheet )
CSS Table Styling.
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
>> The “Box” Model
Advanced CSS BIS1523 – Lecture 20.
Cascading Style Sheets (Formatting)
Box model.
The Box Model in CSS Web Design – Sec 4-8
BOX DIMENSIONS width, height div { height: 300px; width: 400px; background-color: #ee3e80;} p { height: 75%; width: 75%; background-color:
CSS Applications to XML 19-Sep-18.
CSS Table Styling.
CSS Table Styling.
Objectives Create a reset style sheet Explore page layout designs
Cascading Style Sheets
CSS Borders and Margins.
CSS Box Model.
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
Box model, spacing, borders, backgrounds
CSS Box Model.
How to use the CSS box model for spacing, borders, and backgrounds
More CSS 22-Feb-19.
The Box Model.
CSS Box Model.
Laying out Elements with CSS
CSS Boxes CS 1150 Fall 2016.
CS3220 Web and Internet Programming More CSS
CSS Applications to XML 20-May-19.
CS3220 Web and Internet Programming More CSS
CSS Applications to XML 3-Jul-19.
Cascading Style Sheets™ (CSS)
CS3220 Web and Internet Programming More CSS
Presentation transcript:

Cascading Style Sheets Boxes CS 1150 Spring 2017

In This Lecture Controlling size of boxes Box model for borders, margin and padding Displaying and hiding boxes

CSS Boxes In previous lectures, you saw how CSS treats each HTML element as if it lives in its own box You can set several properties that affect the appearance of these boxes Dimensions of boxes Borders of boxes Margins and padding for boxes Showing and hiding boxes

Box Dimensions By default a box is sized just big enough to hold its contents To set your own dimensions for a box, you can use the height and width properties The most popular ways to specify the size of boxes are to use pixels, percentages, or ems Pixels are traditionally the most popular method

Specifying Box Dimensions When you use percentages, the size of the box is relative to the size of the browser window If the box is encased in another box, it is a percentage of the size of the containing box When you use ems, the size of the box is based on the size of the text within it Box dimensions are specified by the CSS properties height and width height: 300px; width: 400px;

Limiting Width Some page designs expand and shrink to fit the size of the user’s screen In such designs, the min-width and min-height properties are used to set the minimum width and height a box can be on a page The max-width and max-height properties are used to set the maximum width and height a box can be on a page

Overflowing Content The overflow property tells the browser what to do if the content contained within a box is larger than the box itself It can have one of two values: overflow: hidden; (This property simply hides any extra content that does not fit in the box) overflow: scroll; (This property adds a scrollbar to the box so that users can scroll to see the missing content) The overflow property is handy because some browsers allow users to adjust the size of the text to appear as large or small as they want. If the text is set too large then the page can become and unreadable mess. Hiding the overflow on such boxes helps prevent items overlapping on the page

Borders, Margin & Padding Border – Every box has a border (even if it is not visible or is specified to be 0 pixels wide). The border separates the edge of one box from another. Margin – Margins sit outside the edge of the border. You can set the width of a margin to create a gap between the borders of two adjacent boxes. Padding – Padding is the space between the border of a box and any content contained within it. Adding padding can increase the readability of its contents.

White Space & Vertical Margin The padding and margin properties are very helpful in adding space between various items on the page Designers refer to the space between items on a page as white space. Imagine you had a border around a box. You would not want the text to touch this border or it would become harder to read. Imagine you had two boxes sitting side by side (each with a black border). You would not necessarily want the boxes to touch edges as this would make the line look twice as thick on the facing sides. If the bottom margin of any box touches the top margin of another, the browser will render it differently than you might expect. It will only show the larger of the two margins. If both margins are the same size, it will only show one.

Border Width border-width is used to control the width of a border. The value of this property either be given in pixels or using one of the following values: border-width: thin; border-width: medium; border-width: thick; You can control the individual size of borders using four separate properties: border-top-width, border-right-width, border-bottom-width, border-left-width You can also specify different widths for the four border values in one property, like so: border-width: 2px 1px 1px 2px; The values here appear in clockwise order: top, right, bottom left

Border Style border-style is used to control the style of a border. The value of this property can take one of the following values: border-style: solid; border-style: dotted; border-style: dashed; border-style: double; border-style: groove; border-style: ridge; border-style: inset; border-style: outset; border-style: hidden; border-style: none; You can control the individual styles of borders using four separate properties: border-top-style, border-right-style, border-bottom-style, border-left-style

Border Color border-color is used to control the color of a border. The value of this property can be specified in RGB values, hex codes, or CSS color names: border-color: darkcyan; You can control the individual colors of borders using four separate properties: border-top-color, border-right-color, border-bottom-color, border-left-color You can also specify different colors for the four border values in one property, like so: border-color: darkcyan hotpink hotpink darkcyan; The values here appear in clockwise order: top, right, bottom left

Border Shorthand The border property allows you to specify the width, style and color of a border in one property The values should be coded in that specific order Example border: 3px dotted darkcyan;

Padding Properties The padding property allows you to specify how much space should appear between the content of an element and its border The value of this property is most commonly specified in pixels (although it is possible to use percentages or ems). If a width is specified for a box, padding is added onto the width of the box You can specify different values for each side of a box using: padding-top, padding-right, padding-bottom, padding-left You can also use shorthand, where the values are in clockwise order: top, right, bottom, left

Margin Properties The margin property controls the gap between boxes. Its value is commonly given in pixels, although you may also use percentages or ems. If one box sits on top of another, margins are collapsed, which means the larger of the two margins will be used and the smaller will be disregarded You can specify values for each side of a box using: margin-top, margin-right, margin-bottom, margin-left You can also use shorthand, where the values are in clockwise order: top, right, bottom, left

Centering Content If you want to center a box on the page (or inside the element it sits in) you can set the left-margin and right-margin values to auto In order to center a box on the page, you need to set a width for the box (otherwise it will take up the full width of the page) In order for this to work in older browsers, the element that the box sits inside should have a text-align property with its value set to center.

Changing Inline/Block The display property allows you to turn an inline element into a block level element or vice versa The values the display property can take are the following: display: inline; (This causes a block level element to act like an inline element) display: block; (This causes a block level element to flow like an inline element, while retaining other features of a block level element) display: none; (This hides an element from the page)

Hiding Boxes The visibility property allows you to hide boxes from users, but it leaves a space where the element would have been This property can take two values: visibility: hidden; visibility: visible;

Rounded Corners The border-radius property allows you to set rounded corners on any box The value is specified in pixels You can specify individual values for each corner of a box using: border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-top-left-radius You can also use a shorthand of these four properties in clockwise order: top, right, bottom, left

Example Files border_margin_padding.css, border_margin_padding.html border_radius.css, border_radius.html box_dimensions.css, box_dimensions.html centering.css, centering.html min_height.css, min_height.html min_width.css, min_width.html overflow.css, overflow.html