国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Tips for implementing the left and right columns contour borders under CSS Flex layout
Home Web Front-end CSS Tutorial How to use CSS Flex to achieve the same height border of left and right layout?

How to use CSS Flex to achieve the same height border of left and right layout?

Apr 05, 2025 pm 07:12 PM
css red

How to use CSS Flex to achieve the same height border of left and right layout?

Tips for implementing the left and right columns contour borders under CSS Flex layout

When using CSS Flex layout, you often need to divide the page into two parts, and the lower part is then subdivided into two columns. If the heights of the left and right columns are not fixed, how can we ensure that the borders that divide them can automatically extend to the highest height? This article provides two solutions to solve this problem.

Scene: The page is divided into two parts, the upper and lower parts, and the lower part adopts a Flex layout. The height of the left and right columns is uncertain, so a border of equal height is needed between the two columns.

Solution 1: jQuery adjustment based on existing structure

If the HTML structure cannot be modified, this method can be used. First, set height: min-content; for the right element (assuming it is .rht ) so that its height is adaptable to the content. Then, use jQuery to get the height of .rht and apply it to the child elements of the left element (assuming it is .lft ):

 let h = $(".rht").height() 'px';
$(".lft div").css({ height: h });

This method relies on JavaScript and needs to be executed after the page is loaded.

Solution 2: Adjust HTML structure and CSS style

This method is simpler and more efficient, without JavaScript. Contour borders can be implemented more elegantly by adjusting HTML structure and CSS styles.

Improved HTML structure:

<div class="wrapper">
  <div class="top">Top content</div> <!-- Top area-->
  <div class="content"> <!-- Flex layout container-->
    <div class="lft">
      <div>Content on the left</div>
    </div>
    <div class="rht">
      <div>Content on the right</div>
    </div>
  </div>
</div>

Corresponding CSS style:

 * {
  padding: 0;
  border: 0;
  margin: 0;
  box-sizing: border-box; /* It is recommended to add to avoid borders affecting element size calculation*/
}

.wrapper {
  height: 100vh; /* Occupies the entire viewport height*/
  display: flex;
  flex-direction: column; /* Vertical layout*/
}

.top {
  height: 100px;
  background: #e3e3e3;
}

.content {
  display: flex;
  flex: 1; /* occupy the remaining space*/
  min-height: 0; /* Prevent minimum height from affecting the layout*/
}

.lft {
  flex: 1; /* occupy the remaining space*/
}

.rht {
  width: 600px;
  border-left: 1px solid red;
  min-height: 0; /* Prevent minimum height from affecting the layout*/
}

In this plan:

  • .wrapper uses flex-direction: column; to achieve vertical layout.
  • .content uses flex: 1; to occupy the remaining space to ensure its height is adaptable.
  • Both .lft and .rht use min-height: 0; to prevent the minimum height from limiting its height.
  • The split line is border-left directly on .rht .

Solution 2 is implemented through pure CSS, which has better performance and is easier to maintain. It is recommended to give priority to the use of Plan 2.

The above is the detailed content of How to use CSS Flex to achieve the same height border of left and right layout?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is 'render-blocking CSS'? What is 'render-blocking CSS'? Jun 24, 2025 am 12:42 AM

CSS blocks page rendering because browsers view inline and external CSS as key resources by default, especially with imported stylesheets, header large amounts of inline CSS, and unoptimized media query styles. 1. Extract critical CSS and embed it into HTML; 2. Delay loading non-critical CSS through JavaScript; 3. Use media attributes to optimize loading such as print styles; 4. Compress and merge CSS to reduce requests. It is recommended to use tools to extract key CSS, combine rel="preload" asynchronous loading, and use media delayed loading reasonably to avoid excessive splitting and complex script control.

External vs. Internal CSS: What's the Best Approach? External vs. Internal CSS: What's the Best Approach? Jun 20, 2025 am 12:45 AM

ThebestapproachforCSSdependsontheproject'sspecificneeds.Forlargerprojects,externalCSSisbetterduetomaintainabilityandreusability;forsmallerprojectsorsingle-pageapplications,internalCSSmightbemoresuitable.It'scrucialtobalanceprojectsize,performanceneed

What are the key differences between inline, block, inline-block, and flex display values? What are the key differences between inline, block, inline-block, and flex display values? Jun 20, 2025 am 01:01 AM

Choosing the correct display value in CSS is crucial because it controls the behavior of elements in the layout. 1.inline: Make elements flow like text, without occupying a single line, and cannot directly set width and height, suitable for elements in text, such as; 2.block: Make elements exclusively occupy one line and occupy all width, can set width and height and inner and outer margins, suitable for structured elements, such as; 3.inline-block: has both block characteristics and inline layout, can set size but still display in the same line, suitable for horizontal layouts that require consistent spacing; 4.flex: Modern layout mode, suitable for containers, easy to achieve alignment and distribution through justify-content, align-items and other attributes, yes

What is Autoprefixer and how does it work? What is Autoprefixer and how does it work? Jul 02, 2025 am 01:15 AM

Autoprefixer is a tool that automatically adds vendor prefixes to CSS attributes based on the target browser scope. 1. It solves the problem of manually maintaining prefixes with errors; 2. Work through the PostCSS plug-in form, parse CSS, analyze attributes that need to be prefixed, and generate code according to configuration; 3. The usage steps include installing plug-ins, setting browserslist, and enabling them in the build process; 4. Notes include not manually adding prefixes, keeping configuration updates, prefixes not all attributes, and it is recommended to use them with the preprocessor.

How can you animate an SVG with CSS? How can you animate an SVG with CSS? Jun 30, 2025 am 02:06 AM

AnimatingSVGwithCSSispossibleusingkeyframesforbasicanimationsandtransitionsforinteractiveeffects.1.Use@keyframestodefineanimationstagesforpropertieslikescale,opacity,andcolor.2.ApplytheanimationtoSVGelementssuchas,,orviaCSSclasses.3.Forhoverorstate-b

2025 policy strangulation warning: These three types of coins will be cleared out, sell them quickly! 2025 policy strangulation warning: These three types of coins will be cleared out, sell them quickly! Jul 03, 2025 am 10:30 AM

The three types of cryptocurrencies that may be liquidated or restricted by regulators in 2025 include: 1. Privacy currency, which is easily used for illegal activities due to its anonymity and faces restrictions or removal from the shelves caused by the strengthening of global AML/KYC regulations; 2. Unregistered securities tokens may be removed from the exchange or required rectification due to non-compliance with securities regulations; 3. Non-compliant stablecoins may be prohibited from trading due to lack of transparent reserves or regulatory permissions. It is recommended to pay close attention to regulatory trends, diversified investment, pay attention to exchange announcements and consult professionals to deal with policy risks.

What is the conic-gradient() function? What is the conic-gradient() function? Jul 01, 2025 am 01:16 AM

Theconic-gradient()functioninCSScreatescirculargradientsthatrotatecolorstopsaroundacentralpoint.1.Itisidealforpiecharts,progressindicators,colorwheels,anddecorativebackgrounds.2.Itworksbydefiningcolorstopsatspecificangles,optionallystartingfromadefin

How to collect airdrops in the currency circle? Are free tokens risky? Airdrop participation strategy How to collect airdrops in the currency circle? Are free tokens risky? Airdrop participation strategy Jul 07, 2025 pm 10:12 PM

Airdrops in the cryptocurrency field are a marketing promotion method for the project to distribute a certain number of tokens for free to community members or potential users. In this way, the project party hopes to increase the visibility of the tokens and attract more users to participate in the project, thereby expanding the size of the community and increasing the liquidity of the tokens. For users, airdrops provide opportunities to obtain project tokens without initial investment, and are one of the ways to get in touch with and understand new projects in the early stage.

See all articles