Web Front-end
CSS Tutorial
Several techniques that can be used when implementing layout with css (code)Several techniques that can be used when implementing layout with css (code)
The content of this article is about several techniques (code) that can be used when implementing CSS layout. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Faced with a familiar layout
The sides are fixed and the middle is adaptive, the head is fixed and the middle is adaptive, the panel component and the model component are similar in appearance
We have a front-end framework Both bootstrap and easyui provide these component plug-ins. During the use process, there are always some slight differences with the page drawn by UI, such as: font, height, background color
Today we will summarize how to quickly customize the layout , improve development efficiency
Option 1: Use positioning to implement the above fixed middle adaptive layout
#section{
position: fixed;
top:0;
left: 0;
bottom: 0;
right: 0;
.top{
position: fixed;
top:0;
left: 0;
height: @header_height;
width: 100%;
}
.main{
position:relative;
top:-@header_height;
left:0;
height:100%;
border-top:@header_height solid transparent;
}
}Principle: Use border-top to occupy the top height, and use the top setting of position-@header_height to top the position Go back
Option 2: Use float, padding, and margin to achieve side-fixed middle adaptive layout
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>padding layout demo</title>
<style type="text/css">
* html #container{
height:1%; /* So IE plays nice */
}
html{
height: 100%;
}
body{
height: 100%;
margin:0;
}
#container{
background-color:#0ff;
overflow:hidden;
height: 100%;
padding-right:220px; /* 宽度大小等与边栏宽度大小*/
}
#content{
background-color:yellow;
width:100%;
float:left;
height: 100%;
}
#sidebar{
background-color:#f00;
width:220px;
float:left;
height: 100%;
margin-right:-220px;
}
</style>
</head>
<body>
<p id="container">
<p id="content">Main content section
</p>
<p id="sidebar">Right Sidebar </p>
</p>
</body>
</html>Principle: Use padding to occupy the side width, and use the side margin setting-@side_width return Go to the side position
Panel layout: The principle is similar to option 1. In addition, modal can also refer to this layout method
html structure
<p class="panel">
<p class="panel-header">
<span class="panel-title-self">今日庭审</span>
</p>
<p class="panel-body">
<p class="trial">
</p>
</p>
</p>css setting
@panel-title-font-size:1rem;
@panel-title-color:#fff;
@panel-title-bg:#30A7FF;
@panel-title-height:2.7rem;
.panel-title-self{
color: @panel-title-color;
font-size: @panel-title-font-size;
background-color: @panel-title-bg;
height: @panel-title-height;
}
.panel{
height: 100%;
border: 1px solid #ddd;
margin: 0;
position: relative;
box-shadow: 3px 3px 3px 3px #ddd;
.panel-header{
background:@panel-title-bg;
padding-left: 10px;
height: @panel-title-height;
line-height: @panel-title-height;
display: flex;
align-items: center;
img{
margin: 0 5px;
}
}
.panel-body{
height: 100%;
width: 100%;
box-sizing: border-box;
border-top:@panel-title-height solid transparent;
padding: 0;
position: relative;
top:-@panel-title-height;
}
}Related recommendations:
How to implement a custom scroll bar style in css3? (Code)
The above is the detailed content of Several techniques that can be used when implementing layout with css (code). For more information, please follow other related articles on the PHP Chinese website!
Draggin' and Droppin' in ReactApr 17, 2025 am 11:52 AMThe React ecosystem offers us a lot of libraries that all are focused on the interaction of drag and drop. We have react-dnd, react-beautiful-dnd,
Fast SoftwareApr 17, 2025 am 11:49 AMThere have been some wonderfully interconnected things about fast software lately.
Nested Gradients with background-clipApr 17, 2025 am 11:47 AMI can't say I use background-clip all that often. I'd wager it's hardly ever used in day-to-day CSS work. But I was reminded of it in a post by Stefan Judis,
Using requestAnimationFrame with React HooksApr 17, 2025 am 11:46 AMAnimating with requestAnimationFrame should be easy, but if you haven’t read React’s documentation thoroughly then you will probably run into a few things
Need to scroll to the top of the page?Apr 17, 2025 am 11:45 AMPerhaps the easiest way to offer that to the user is a link that targets an ID on the element. So like...
The Best (GraphQL) API is One You WriteApr 17, 2025 am 11:36 AMListen, I am no GraphQL expert but I do enjoy working with it. The way it exposes data to me as a front-end developer is pretty cool. It's like a menu of
Weekly Platform News: Text Spacing Bookmarklet, Top-Level Await, New AMP Loading IndicatorApr 17, 2025 am 11:26 AMIn this week's roundup, a handy bookmarklet for inspecting typography, using await to tinker with how JavaScript modules import one another, plus Facebook's
Various Methods for Expanding a Box While Preserving the Border RadiusApr 17, 2025 am 11:19 AMI've recently noticed an interesting change on CodePen: on hovering the pens on the homepage, there's a rectangle with rounded corners expanding in the back.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment





