The CSS box model allows web pages to be laid out using boxes or containers. Each box has content, padding, borders, and margins. The <div> tag is used to define boxes and reserve space on the page. Box dimensions can be specified in pixels or percentages. Padding, borders, and margins are added to the defined width and height to calculate the total box size. Margins can be set to "auto" to center a <div> horizontally on the page regardless of screen width.
Using this presentation you will learn dividing the browser window into different parts(frame). With frames, several Web pages can be displayed in the same browser window.
The document discusses responsive web design using CSS media queries and frameworks like Bootstrap. It covers viewport meta tags, CSS grid systems, and how to make layouts responsive at different screen sizes. Key components in Bootstrap like containers, rows, and columns are explained to help structure responsive web pages. Media queries allow applying styles based on screen width, and frameworks like Bootstrap simplify creating mobile-first responsive designs.
This presentation introduces responsive web design which allows websites to automatically adapt their layout to different screen sizes. It discusses using a flexible grid system, flexible images and media, and media queries to create a single adaptive design. The strategy is to use a linear mobile-first approach and progressively enhance the design for larger screens using media queries. This allows the site to work on any device while providing the best experience for each form factor.
Não é nenhum segredo que o mundo está cada vez mais móvel. As vendas de PCs caíram em 20% desde 2008, e em 2015 é esperado que o acesso à Internet por dispositivos portáteis supere o acesso por desktops. A Web pode ser acessada de qualquer lugar, a qualquer hora. Mas com tantos modelos de dispositivos—tablets, notebooks, netbooks e smartphones—como fazer com que seu produto funcione em todos?
O Responsive Web Design—um conjunto de técnicas e ideologias—promete solucionar este problema, oferecendo o mesmo conteúdo em todas as plataformas, da melhor maneira. Nesta palestra, serão ensinadas técnicas de design, front e back-end para que seu site seja usável e acessível por todos, sem limitar-se a modelos, tamanhos de tela ou versões específicas.
This document discusses different web page layout techniques, including fixed and fluid/liquid layouts. Fixed layouts use pixel values to set widths and do not adapt to different screen sizes, while fluid layouts expand and contract to fill the screen. It also covers semantic HTML elements that provide meaning, like header, nav, aside, main, and footer. Specific examples are given for creating a two-column fixed layout with these semantic elements, including styling the container, header, navigation, sidebar, main content, and footer sections. Positioning techniques like floats and relative positioning are also discussed.
The CSS box model describes the layout of elements using boxes. Each element is represented as a box that consists of margins, borders, padding, and content. Media queries allow CSS rules to be applied conditionally based on characteristics of the device such as screen width, orientation, and resolution. Common uses of media queries include adjusting layouts for mobile devices and changing element properties based on screen size.
The document discusses grid systems in web design. It explains that grid systems use ratios and measurements to construct layouts with fixed or flexible widths. For fixed grids, the canvas size is based on screen resolution, while flexible grids scale to browser windows. The document also describes creating grids in Photoshop, using background images for alignment, and the 960 Grid System CSS framework which enables rapid prototyping with 12 or 16 column grids within a 960px container.
This document provides a two-part tutorial on creating a basic webpage with HTML and CSS. The first part covers the HTML structure, including adding divs for the header, content, sidebar, and footer. The second part covers styling the HTML elements with CSS, including setting widths, heights, colors and positioning for each section. Styling is applied to elements like the wrapper, header, content, sidebar and footer. The tutorial provides the necessary CSS code to style each element and position them on the page. Once completed, the basic webpage structure and styling is finished but no actual content is added yet.
This document introduces the concept of responsive web design. It notes that the number of mobile devices now exceeds desktop computers and the mobile web will surpass the desktop internet by 2015. It then discusses responsive design, which involves creating websites that automatically adjust their layout depending on device and screen size using fluid grids, flexible images and media queries. Examples of responsive sites and resources for learning more are provided.
This document contains CSS3 notes from Rex Wang from December 2015 in Auckland. It lists over 20 references to CSS topics on w3schools.com including fonts, tables, positioning, box model, and CSS3 properties. The notes cover basic CSS syntax and selectors, how to insert CSS, background properties, borders, margins and padding, width and height, text and link styling, lists and tables. It also covers the box model, outlines, layout with the display property, and different positioning methods.
Media queries allow changing layout without changing content by detecting screen size. Layouts can differ based on screen width breakpoints specified in CSS media queries. Viewport meta tags ensure proper rendering on mobile. Flexbox provides an alternative to floats for layout, making elements flex items within a flex container to arrange them flexibly based on properties like direction and wrapping. Figures group related images and captions for informational purposes.
This document discusses various CSS properties for controlling web page layout and positioning of elements. It covers the CSS box model including margins, borders, padding and content, and properties for defining dimensions, positioning, floats and more. Examples are provided for setting widths, heights, paddings, borders, the display property, and using relative, fixed and absolute positioning.
Frames divide the browser window into separate panes, each containing an HTML document. This allows reloading individual panes without reloading the entire browser window. The window is divided using rows and columns defined by the <frameset> element. Each frame displays a document defined by its <frame> src attribute. Browsers that do not support frames will show content in the <noframes> element. Inline frames (<iframe>) also display separate documents but within the main document flow rather than in a divided window.
This document provides instructions for using CSS overrides to create customized landing pages in a template-based CMS like Sitecore. It introduces a framework called custom-lp.css that defines classes to structure landing page content without constraints from templates. Styles, HTML and text can be added directly in the editor. The framework is responsive, with styles for desktop, tablet and mobile. Tips are provided for common issues like inline-block gaps, column width bugs, and stubborn style overrides.
Frames divide a browser window into separate panes, each containing an HTML document. This allows reloading individual panes without reloading the entire browser window. A collection of frames is called a frameset. Framesets use <frameset> tags to define rows and columns, with each frame represented by <frame> tags specifying its source document. Inline frames (<iframe>) embed separate documents into the main page.
Frames divide a browser window into multiple panes, each containing a separate HTML document. A collection of frames is called a frameset. The <frameset> element replaces the <body> element and is used to define the rows and columns of frames. Individual <frame> elements are used within the <frameset> to specify sources for each frame. Attributes like name, target, and scrolling can be used to control frames. The <iframe> element defines an inline frame for embedding another document within the current one.
This document provides an agenda and information for FEWD Week 3. It discusses units of measurement like pixels, percentages and ems. It also covers font sizing, layouts like static, liquid, adaptive and responsive designs. Media queries and flexbox are introduced as tools for responsive layouts. Students are assigned to continue working on the Relaxr project and learn about units, layouts, media queries and flexbox through examples and exercises.
This document provides information about HTML frames including:
- Frames allow dividing the browser window into multiple panes using <frameset> and <frame> tags.
- <frameset> defines the layout as rows or columns and <frame> defines each individual pane.
- Attributes like name, src, scrolling control frame behavior.
- Targeting links to different frames uses the target attribute.
- Nested <frameset> allow complex layouts with rows and columns.
- <noframes> provides content for non-frame browsers.
Media queries is very important for developing Modern Websites. This slide will guide you about Media queries. After watching this, you don't need any other tutorial or lessons.
Frames allow dividing a browser window into sections that can each load separate HTML documents. The <frameset> tag replaces the <body> tag and defines how to divide the window into rows and columns using frames. Each frame loads a document using the <frame> tag. Inline frames using <iframe> can embed another document anywhere in a page.
Responsive Web Design: From Mobile To Desktop, And Beyond (updated for MobiDe...gravityworksdd
The document discusses responsive web design. It begins by asking what responsive design is, why it should be used, and how to create a responsive layout. It then provides details on some basic components of responsive design like using a flexible grid layout, flexible images, and media queries. The document outlines several responsive menu options including flowing the menu onto two lines, switching to a vertical or expandable button menu, or using a dropdown select menu on small screens. It emphasizes using fluid images, videos, and fonts as well as media queries to make layout adjustments at different breakpoints.
This document discusses different types of page layouts including fixed and flexible layouts using <table>, <div> elements, and HTML5 elements. It provides examples of creating two-column layouts with navigation on the left and content on the right using <table> and <div> elements. It also discusses properties like float, display, and clear that can be used to control layout positioning.
To define responsive web design means that your website (and its pages) can adapt and deliver the best experience to users, whether they’re on their desktop, laptop, tablet, or smartphone. For that to happen, though, your website needs a responsive design.
The document discusses grid systems in web design. It explains that grid systems use ratios and measurements to construct layouts with fixed or flexible widths. For fixed grids, the canvas size is based on screen resolution, while flexible grids scale to browser windows. The document also describes creating grids in Photoshop, using background images for alignment, and the 960 Grid System CSS framework which enables rapid prototyping with 12 or 16 column grids within a 960px container.
This document provides a two-part tutorial on creating a basic webpage with HTML and CSS. The first part covers the HTML structure, including adding divs for the header, content, sidebar, and footer. The second part covers styling the HTML elements with CSS, including setting widths, heights, colors and positioning for each section. Styling is applied to elements like the wrapper, header, content, sidebar and footer. The tutorial provides the necessary CSS code to style each element and position them on the page. Once completed, the basic webpage structure and styling is finished but no actual content is added yet.
This document introduces the concept of responsive web design. It notes that the number of mobile devices now exceeds desktop computers and the mobile web will surpass the desktop internet by 2015. It then discusses responsive design, which involves creating websites that automatically adjust their layout depending on device and screen size using fluid grids, flexible images and media queries. Examples of responsive sites and resources for learning more are provided.
This document contains CSS3 notes from Rex Wang from December 2015 in Auckland. It lists over 20 references to CSS topics on w3schools.com including fonts, tables, positioning, box model, and CSS3 properties. The notes cover basic CSS syntax and selectors, how to insert CSS, background properties, borders, margins and padding, width and height, text and link styling, lists and tables. It also covers the box model, outlines, layout with the display property, and different positioning methods.
Media queries allow changing layout without changing content by detecting screen size. Layouts can differ based on screen width breakpoints specified in CSS media queries. Viewport meta tags ensure proper rendering on mobile. Flexbox provides an alternative to floats for layout, making elements flex items within a flex container to arrange them flexibly based on properties like direction and wrapping. Figures group related images and captions for informational purposes.
This document discusses various CSS properties for controlling web page layout and positioning of elements. It covers the CSS box model including margins, borders, padding and content, and properties for defining dimensions, positioning, floats and more. Examples are provided for setting widths, heights, paddings, borders, the display property, and using relative, fixed and absolute positioning.
Frames divide the browser window into separate panes, each containing an HTML document. This allows reloading individual panes without reloading the entire browser window. The window is divided using rows and columns defined by the <frameset> element. Each frame displays a document defined by its <frame> src attribute. Browsers that do not support frames will show content in the <noframes> element. Inline frames (<iframe>) also display separate documents but within the main document flow rather than in a divided window.
This document provides instructions for using CSS overrides to create customized landing pages in a template-based CMS like Sitecore. It introduces a framework called custom-lp.css that defines classes to structure landing page content without constraints from templates. Styles, HTML and text can be added directly in the editor. The framework is responsive, with styles for desktop, tablet and mobile. Tips are provided for common issues like inline-block gaps, column width bugs, and stubborn style overrides.
Frames divide a browser window into separate panes, each containing an HTML document. This allows reloading individual panes without reloading the entire browser window. A collection of frames is called a frameset. Framesets use <frameset> tags to define rows and columns, with each frame represented by <frame> tags specifying its source document. Inline frames (<iframe>) embed separate documents into the main page.
Frames divide a browser window into multiple panes, each containing a separate HTML document. A collection of frames is called a frameset. The <frameset> element replaces the <body> element and is used to define the rows and columns of frames. Individual <frame> elements are used within the <frameset> to specify sources for each frame. Attributes like name, target, and scrolling can be used to control frames. The <iframe> element defines an inline frame for embedding another document within the current one.
This document provides an agenda and information for FEWD Week 3. It discusses units of measurement like pixels, percentages and ems. It also covers font sizing, layouts like static, liquid, adaptive and responsive designs. Media queries and flexbox are introduced as tools for responsive layouts. Students are assigned to continue working on the Relaxr project and learn about units, layouts, media queries and flexbox through examples and exercises.
This document provides information about HTML frames including:
- Frames allow dividing the browser window into multiple panes using <frameset> and <frame> tags.
- <frameset> defines the layout as rows or columns and <frame> defines each individual pane.
- Attributes like name, src, scrolling control frame behavior.
- Targeting links to different frames uses the target attribute.
- Nested <frameset> allow complex layouts with rows and columns.
- <noframes> provides content for non-frame browsers.
Media queries is very important for developing Modern Websites. This slide will guide you about Media queries. After watching this, you don't need any other tutorial or lessons.
Frames allow dividing a browser window into sections that can each load separate HTML documents. The <frameset> tag replaces the <body> tag and defines how to divide the window into rows and columns using frames. Each frame loads a document using the <frame> tag. Inline frames using <iframe> can embed another document anywhere in a page.
Responsive Web Design: From Mobile To Desktop, And Beyond (updated for MobiDe...gravityworksdd
The document discusses responsive web design. It begins by asking what responsive design is, why it should be used, and how to create a responsive layout. It then provides details on some basic components of responsive design like using a flexible grid layout, flexible images, and media queries. The document outlines several responsive menu options including flowing the menu onto two lines, switching to a vertical or expandable button menu, or using a dropdown select menu on small screens. It emphasizes using fluid images, videos, and fonts as well as media queries to make layout adjustments at different breakpoints.
This document discusses different types of page layouts including fixed and flexible layouts using <table>, <div> elements, and HTML5 elements. It provides examples of creating two-column layouts with navigation on the left and content on the right using <table> and <div> elements. It also discusses properties like float, display, and clear that can be used to control layout positioning.
To define responsive web design means that your website (and its pages) can adapt and deliver the best experience to users, whether they’re on their desktop, laptop, tablet, or smartphone. For that to happen, though, your website needs a responsive design.
software evelopment life cycle model and example of water fall modelvishal choudhary
studying the existing or obsolete system and software,
conducting interviews of users and developers,
referring to the database or
collecting answers from the questionnaires.
software Engineering lecture on development life cyclevishal choudhary
SDLC starts from the moment, when it’s made a decision to launch the project.
There is no one single SDLC model.
They are divided into groups,
Each with its features and weaknesses
The document provides an introduction to software engineering. It defines software engineering as an engineering discipline concerned with all aspects of software production. It discusses why software engineering is important given that errors in complex software systems can have devastating consequences, as shown through examples of software failures in air traffic control, satellite launches, and ambulance dispatch systems. The document also covers fundamental software engineering concepts like the software process, process models, and costs.
The document discusses software testing concepts like validation testing vs defect testing, system and component testing strategies, and test automation tools. It defines key terms like bugs, defects, errors, faults, and failures. It also describes techniques like equivalence partitioning and boundary value analysis that are used to generate test cases that thoroughly test software. Component testing tests individual program parts while system testing tests integrated groups of components. Test cases specify conditions to determine if software works as intended.
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsesushreesangita003
what is pulse ?
Purpose
physiology and Regulation of pulse
Characteristics of pulse
factors affecting pulse
Sites of pulse
Alteration of pulse
for BSC Nursing 1st semester
for Gnm Nursing 1st year
Students .
vitalsign
How to Set warnings for invoicing specific customers in odooCeline George
Odoo 16 offers a powerful platform for managing sales documents and invoicing efficiently. One of its standout features is the ability to set warnings and block messages for specific customers during the invoicing process.
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
Multi-currency in odoo accounting and Update exchange rates automatically in ...Celine George
Most business transactions use the currencies of several countries for financial operations. For global transactions, multi-currency management is essential for enabling international trade.
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...larencebapu132
This is short and accurate description of World war-1 (1914-18)
It can give you the perfect factual conceptual clarity on the great war
Regards Simanchala Sarab
Student of BABed(ITEP, Secondary stage)in History at Guru Nanak Dev University Amritsar Punjab 🙏🙏
Odoo Inventory Rules and Routes v17 - Odoo SlidesCeline George
Odoo's inventory management system is highly flexible and powerful, allowing businesses to efficiently manage their stock operations through the use of Rules and Routes.
Exploring Substances:
Acidic, Basic, and
Neutral
Welcome to the fascinating world of acids and bases! Join siblings Ashwin and
Keerthi as they explore the colorful world of substances at their school's
National Science Day fair. Their adventure begins with a mysterious white paper
that reveals hidden messages when sprayed with a special liquid.
In this presentation, we'll discover how different substances can be classified as
acidic, basic, or neutral. We'll explore natural indicators like litmus, red rose
extract, and turmeric that help us identify these substances through color
changes. We'll also learn about neutralization reactions and their applications in
our daily lives.
by sandeep swamy
Geography Sem II Unit 1C Correlation of Geography with other school subjectsProfDrShaikhImran
The correlation of school subjects refers to the interconnectedness and mutual reinforcement between different academic disciplines. This concept highlights how knowledge and skills in one subject can support, enhance, or overlap with learning in another. Recognizing these correlations helps in creating a more holistic and meaningful educational experience.
How to Subscribe Newsletter From Odoo 18 WebsiteCeline George
Newsletter is a powerful tool that effectively manage the email marketing . It allows us to send professional looking HTML formatted emails. Under the Mailing Lists in Email Marketing we can find all the Newsletter.
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessMark Soia
Boost your chances of passing the 2V0-11.25 exam with CertsExpert reliable exam dumps. Prepare effectively and ace the VMware certification on your first try
Quality dumps. Trusted results. — Visit CertsExpert Now: https://www.certsexpert.com/2V0-11.25-pdf-questions.html
2. Finding the width in percentage of a 200px div inside a 1000px
container:
200 / 1000 = .2
=> Move decimal place over two to the right and this leaves you
with 20% width.
target / context. The context for regular width and for margin is based on the containing
element.
3. Convert left and right padding of a div to percentage where padding is
10px and element width is 350px and everything is inside a 1000px
container.
• Here we disregard the overall container since we are dealing with padding
leaving us with context being 350px and the target of 10px. Our left and
right padding would then be:
10 / 350 = 0.02857142857142857 (Keep entire decimal to make sure everything is
mathematically perfect) => Move decimal point over two to the right leaving you with
2.857142857142857% left and right padding.
4. Target/context then move the decimal
two places to the right.
let's say a div is 640px and you need 20px in padding converted to %.
20px/640px = 0.03125 = 3.125%
5. p
{ margin: 0;
}
body {
color: pink;
}
.container {
max-width: 500px;
}
.icing {
background-color: green; width: 100%; /500px/
}
.cake { background-color: blue; width: 80%; /400px/ }
.filling { background-color: brown; width: 60%; /300px/ }
Divide the width of the image by the width of the
containing element and then times it by 100. So, a
500px image in a 1000px container would be
500/1000=0.5 x 100 = 50%.
6. If you set the width of an image to 50%, this does not mean that the
image will display at half of its normal size.
• If an image is actually 600 pixels wide, then using a CSS value to display it at 50%
does not mean that it will be 300 pixels wide in the web browser.
• This percentage value is calculated based on the element that contains that image,
not the actual size of the image itself.
• If the container (which could be a division or some other HTML element) is 1000
pixels wide, then the image will display at 500 pixels since that value is 50% of the
container’s width.
• If the containing element is 400 pixels wide, then the image will only display at 200
pixels, since that value is 50% of the container. The image in question here has a
50% size which depends completely on the element which contains it.
7. Browser windows remain at 2000 pixels wide, but we change the
percentage value of the container to 80% instead of 90%. That means
that it will render at 1600 pixels wide now (2000 x .80 = 1600).
8. % To Px Converter
There are a lot of ways to convert between percentage and pixels. You can use an online
calculator, or you can do the math yourself. To convert from percentage to pixels, you
need to know the width or height of the element in pixels. Let’s say you have an
element that is 300px wide, and you want to convert a percentage value to pixels.
To do that, you would multiply the percentage by 300. So, if you have a percentage
value of 50%, that would be 50% * 300px = 150px.
9. What unit you use depends entirely on what you want
to accomplish. The units most used in web layouts
are:
• px - absolute; one pixel
• pt - absolute; 1/72 inch, about 1.3px for screen media
• em - relative to parent font size; 1.0em = size of a character (width of uppercase
M)
• % - relative to parent
You use px for sizes that remain constant, for example a 1px border.
You use em for sizes that should follow the font size, for example a 3.0em margin.
You use % for sizes that should take up a percentage of the parent, for example a
50% width.
For web page layouts you normally use either pixels or percentages depending on
if you want a fixed (pixel) layout or a fluid (percentage) based layout.
10. When creating a responsive webpage, you generally want to avoid using
fixed dimensions for elements, as this can hinder the adaptability of the
layout to various screen sizes. However, there might be cases where you
still want to set some fixed dimensions while maintaining
responsiveness.
11. you might use fixed dimensions within a responsive layout:
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-sizing: border-box;
}
.fixed-element {
width: 300px; /* Fixed width */
height: 200px; /* Fixed height */
background-color: #3498db;
color: #fff;
text-align: center;
line-height: 200px;
margin: 20px auto;
}
@media only screen and (max-width: 768px) {
/* Adjustments for smaller screens */
.container {
width: 90%;
}
.fixed-element {
width: 100%; /* Full width on smaller screens */
height: auto; /* Auto height based on content */
}
}
</style>
<body>
<div class="container">
<h1>Responsive Webpage with Fixed Dimensions</h1>
<div class="fixed-element">Fixed Element</div>
<!-- Other responsive content goes here -->
</div>
</body>
12. • The .container class is set to 80% of the viewport width, providing a
responsive container.
• The .fixed-element class has fixed dimensions of 300px width and
200px height, creating a fixed-size box within the responsive layout.
• Additionally, a media query is used to make adjustments for smaller
screens (widths up to 768px). In this case, the container width is
increased to 90%, and the fixed element is set to take the full width of
its parent container while adjusting the height automatically based on
content.
Keep in mind that using fixed dimensions may limit the flexibility of
your design on various devices, so it's often a good idea to use them
judiciously and consider alternative layout strategies when necessary.
13. A percentage-based layout is crucial for creating fluid and responsive designs in CSS. Below is an example
of a simple percentage-based layout where the width of the elements is defined in percentages, making the
layout adaptable to different screen sizes.
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%; /* Container takes 80% of the viewport width */
margin: 0 auto; /* Center the container */
background-color: #fff;
padding: 20px;
box-sizing: border-box;
}
.column {
width: 45%; /* Each column takes 45% of the container width */
float: left;
margin-right: 5%; /* Add some spacing between columns */
background-color: #3498db;
color: #fff;
text-align: center;
padding: 20px;
box-sizing: border-box;
}
/* Clearfix to ensure container expands to contain floated columns */
.container::after {
content: "";
display: table;
clear: both;
}
@media only screen and (max-width: 768px) {
/* Adjustments for smaller screens */
.container {
width: 90%; /* Container takes 90% of the viewport width on smaller screens */
}
.column {
width: 100%; /* Each column takes full width on smaller screens */
margin-right: 0; /* No spacing between columns on smaller screens */
}
}
</style>
</head>
<body>
<div class="container">
<div class="column">Column 1</div>
<div class="column">Column 2</div>
</div>
</body>
The .container class takes 80% of the viewport width, providing a responsive container.
The .column class has a width of 45% with some spacing between columns. On smaller screens (up to 768px), it adjusts to take the full width, and the spacing between
columns is removed.
This percentage-based layout ensures that the columns adapt to different screen sizes while maintaining a proportional relationship to the container width. The use of a
media query further enhances the responsiveness of the layout for smaller screens. Adjust the percentages and styles based on your specific design requirements.
14. <style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%; /* Container takes 80% of the viewport width */
margin: 0 auto; /* Center the container */
background-color: #fff;
padding: 20px;
box-sizing: border-box;
}
.column {
width: calc((300px / 960px) * 100%); /* Target/Context formula for column width */
float: left;
margin-right: calc((20px / 960px) * 100%); /* Target/Context formula for margin */
background-color: #3498db;
color: #fff;
text-align: center;
padding: 20px;
box-sizing: border-box;
}
/* Clearfix to ensure container expands to contain floated columns */
.container::after {
content: "";
display: table;
clear: both;
}
@media only screen and (max-width: 768px) {
/* Adjustments for smaller screens */
.container {
width: 90%; /* Container takes 90% of the viewport width on smaller screens */
}
.column {
width: 100%; /* Each column takes full width on smaller screens */
margin-right: 0; /* No spacing between columns on smaller screens */
}
}
</style>
</head>
<body>
<div class="container">
<div class="column">Column 1</div>
<div class="column">Column 2</div>
</div>
</body>
</html>
In responsive web design, you can use the formula width = (target / context) * 100% to create a fluid and responsive layout. The target represents the desired
width of an element, and the context is the width of the containing element.
The .column class uses the calc function to apply the target/context formula for both the width and the margin.
The target width for the column is set to 300px, and the margin between columns is set to 20px.
The context width is the width of the .container (which is 960px in this case).
The formula (target / context) * 100% is used to calculate the percentage-based width and margin for the columns.
This way, the columns will adapt their width and margin proportionally based on the size of the container, providing a responsive layout. Adjust the target and context values according to
your design requirements.