Home Web Front-end HTML Tutorial Make div width adaptive for teaching

Make div width adaptive for teaching

Nov 29, 2017 am 11:46 AM
width teaching

We all know that in CSS layout, when no style is set for the div, the div occupies an exclusive row and the default CSS style is 100% width. So this time we will teach you how to implement DIV width adaptive but the width increases from zero with the content. And the width increases? Instead of setting the width to 100% of the full screen from the beginning

Solution:

Use CSS float to make the div default 100% adaptive width to the width from Zero-based adaptive width effect.

css small case of implementing div width from scratch

1. Complete HTML+CSS code

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8" /> 
<title>小实例</title> 
<style> 
.case{ float:left} 
</style> 
</head> 
<body> 
<div>未设置float内容一</div> 
<div>未设置float内容二</div> 
<div class="case">加float样式的内容三</div> 
<div class="case">对其加float样式的内容四</div> 
</body> 
</html>
Copy after login

Key code: add floatfloating style to div , so that its width does not start at 100%, but changes with the content, just like the initial width of span, it widens as the content increases.

Summary:

Setting float on a div through CSS removes the default full-screen width style of the div, but generally you need to use such a box that adapts the content width from scratch, and you cannot use the float floating style. This can be achieved by using the span tag.

I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to the php Chinese website Other related articles!


Related reading:

How to change the mouseover style without using CSS

Js operation Process of DOM object

Calling css file methods of different resolutions

The above is the detailed content of Make div width adaptive for teaching. 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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

Teach you how to remotely control other people's computers in win10 Teach you how to remotely control other people's computers in win10 Jul 14, 2023 am 09:09 AM

In the process of using the win10 system, there are some operations that we do not understand and need to be solved by letting others remotely control our computers. Recently, some users want to know how to remotely control other people's computers with Win 10, so today I will teach you how to remotely control other people's computers with Win 10. Let’s take a look below! How to remotely control other people's computers in win10: 1. Press the win key + i key to open the system. 2. Click Remote Desktop on the left, and then enable Remote Desktop. 3. Click Confirm. 4. Click Advanced Settings, perform security settings and add accounts, and then you can turn on computer remote control! The above is about how to remotely control other people’s computers in win10! hope

Binance cancellation of account teaching: What should I do if I didn't enter the recommendation code? Delete the account and register again! Binance cancellation of account teaching: What should I do if I didn't enter the recommendation code? Delete the account and register again! Mar 04, 2025 am 07:06 AM

Completely understand the process and precautions for deleting Binance account! This article will guide you in detail on how to delete a Binance account and provide key things to check before deleting it. Reasons for deleting Binance Account Analysis Users may choose to delete Binance Account for the following reasons: No recommendation code is filled in: Many users did not fill in the recommendation code when registering and missed the handling fee discount. Since Binance does not support post-fill filling, deleting an account and re-registering is the only solution. Change the exchange: The user may choose to change the exchange due to interface, functions or verification procedures, and decide to delete the Binance account. Security concerns: Exchange security incidents may cause users to worry and choose to delete accounts to reduce risks. Please be sure to confirm the process of deleting Binance account before deleting the account

Detailed explanation of Java virtual machine installation process: teach you step-by-step installation steps Detailed explanation of Java virtual machine installation process: teach you step-by-step installation steps Jan 05, 2024 pm 03:58 PM

Java Virtual Machine Installation Guide: Teach you step by step how to install, need specific code examples Introduction: Java Virtual Machine (JavaVirtualMachine, referred to as JVM) is a virtual machine that can run Java bytecode. It is a core component of Java technology and the key to Java applications being able to run across platforms. In this article, we will teach you step by step how to install a Java virtual machine and provide specific code examples to help you get started quickly. 1. Download JavaDev

Teach you how to record screen on win7 computer Teach you how to record screen on win7 computer Jul 18, 2023 pm 06:09 PM

Generally, Windows systems have their own screen recording function, so if we need to record some computer tutorials and other videos, in addition to using third-party tools, we can also use the system's own tools to record the screen. So how to record screen on win7 computer? The editor below will teach you how to record the screen of your win7 computer. The specific method is as follows: 1. Use the shortcut key "Win+R" to quickly open the run window, enter "psr.exe" in the run window, click OK, and the "Problem Step Recorder" window will pop up. This is the screen recorder . 2. Click the triangle button in the upper right corner of the "Problem Step Recorder" window, click Settings, and the "Problem Step Recorder Settings" window will pop up, where you can save the path of the recorded file. 3. Click

Teach you step by step to develop your own online library using PHP Teach you step by step to develop your own online library using PHP Oct 27, 2023 pm 07:14 PM

Teach you step by step to develop your own online library using PHP. With the development of Internet technology, more and more people are beginning to use the Internet to obtain information and enjoy services. In this context, online libraries emerged as the times require. Online libraries not only provide people with convenient book borrowing services, but also meet users' needs through online reading and search functions. In this article, I will teach you step by step how to develop your own online library using PHP language. Whether you are a beginner or someone with some development experience, you can master the relevant concepts through this article.

Three major scenes + five new products, Qingsong Optoelectronics new product launch conference creates new interactive experience Three major scenes + five new products, Qingsong Optoelectronics new product launch conference creates new interactive experience Apr 19, 2024 pm 03:00 PM

Thirty-two years ago, the founder of Qingsong Optoelectronics lit up the first outdoor full-color LED screen in China, ushering in a new era of LED display technology. After more than thirty years of ups and downs, Qingsong Optoelectronics has always stood at the forefront of science and technology and walked with the horizon. Since joining CVTE in 2018, it has ranked first in the domestic market share of LED all-in-one machines for five consecutive years. On April 17, Qingsong Optoelectronics’ 2024 spring press conference was held as scheduled. During the period, Qingsong Optoelectronics launched three major scenes and five new products, which were full of highlights! Comprehensive attack on the three major scenarios to create a new intelligent interactive experience. Qingsong Optoelectronics has launched a series of differentiated solutions for the three major scenarios of conferences, education, and exhibitions, aiming to bring users a more convenient and efficient new interactive experience. In the meeting scene, Qingsong

How to use win7 memo gadget Experts teach you how to use win7 memo gadget How to use win7 memo gadget Experts teach you how to use win7 memo gadget Jul 07, 2023 pm 11:33 PM

The built-in memo tool in Win7 can not only serve as a reminder, but can also better plan our lives and improve life and work efficiency. But where is the memo tool in Wind7? Some users are not familiar with the use and opening method of the memo tool in Win7. For this reason, the editor will share with you how to use the memo gadget in win7. 1. Open the navigation start button in the lower left corner and enter "Notes" in the search location. 2. After a while, the note program icon will appear, as shown in the picture, click to open it. Of course, if it's a little more troublesome, you can click "Start->Attachments->Notes" 3. Notes will appear on the right side of the desktop, and you can enter your plans or personal notes. So you can write things down

See all articles