Table of Contents
Reply to the discussion (solution)
Home Web Front-end HTML Tutorial After using Baidu Map API, the large picture on the homepage will burst the div in the mobile browser_html/css_WEB-ITnose

After using Baidu Map API, the large picture on the homepage will burst the div in the mobile browser_html/css_WEB-ITnose

Jun 24, 2016 am 11:58 AM
api div Condition front page

The reason is this
I was working on a company website these days and wanted to make a domineering map, so I thought of Baidu API
Then I went to the website and found the code. Unfortunately, the maximum width can only be 567px
But this is not suitable for For code experts, this is not a problem at all. Newbies like me also know how to change the source code
So I changed the width to 100%

Then the code for the first picture is like this

.top {	height:100vh;	width:100%;	background:url(../images/background-1.jpg) no-repeat center top;	background-size:cover;}
Copy after login

<section class="top">...</section>
Copy after login


I think there is no problem
Then I tested it in the browser
This is what the browser looks like

It’s not bad

Then the same thing happens when the browser width is reduced
I haven’t written the 320px adaptive code yet, so it’s very messy. But that’s not the point


But it will become a mobile browser That’s it! ! ! (I'm using ios7)




I'm really fainted. This picture burst the DIV perfectly and overflowed several pages
How can this give people Good experience

Delete the JS code of Baidu API and this problem will disappear
So it must be related to this code of Baidu
But with my strength
I can’t find it. come out. . . . Crying

Please help me take a look
I am giving you the server address because the domain name has not been resolved yet. . .
Just take a look http://121.40.157.215

If you know the problem, you can kindly tell me directly
If you don’t know the problem, you can suggest a method and I will test it

But I’m really a novice. I’m not very good at writing HTML and CSS.
So I really can’t do the part of checking the JS code

Thank you


Reply to the discussion (solution)

1. Method 1 to prevent the image from breaking the DIV - TOP

The original processing method is to process the image to be displayed. For example, if your DIV width is 500px (pixels), then the width of the image you upload or place on the webpage must be less than 500px. That is to say, your image needs to be cut by image software and scaled down before uploading and placing it on the webpage. Solve the problem of broken and opened DIV.

It is common for many large picture sites and news sites to edit photos and images to adapt to the width of the web page.
2. Method 2 to prevent pictures from stretching the DIV - TOP

If you do not use the photo processing method to adapt to the limited width of the DIV, you can set the Hide Exceeding Content method on the DIV. You only need to set the width of the DIV and then add the CSS style "overflow:hidden" to solve the problem of the hidden image being too wide than the DIV and the problem of bursting the DIV.
3. Solution 3 - TOP

Just add the width to the image img tag to solve the problem. This can reduce the image proportionally without affecting the image quality.

For example, if your webpage DIV width is 500px, then you can set the width of the img tag to less than 500 after uploading the image.
This can solve the problem that the DIV SPAN is burst due to the picture being too wide. This has the advantage that the picture can be enlarged and reduced in equal proportions.
4. CSS method to solve the burst problem 4 - TOP

This method uses CSS to directly set the width of the img in the div. The bad thing about this is that if the image is too small, it will affect the effect of browsing the image on the web page.

Div structure:


Corresponding CSS code: .divcss5 img{width: width value unit}
5. CSS method to solve the problem of broken images and DIVs - TOP

Use max-width (maximum width). For example, if your DIV width is 500px, then you should add the maximum width CSS style "max" corresponding to the DIV style. -width="500px"" can be solved, but this attribute is not compatible with IE6 browsers.
6. Summary and recommendations of methods to solve the problem of pictures breaking the DIV layer - TOP

1), maximum width ( max-width) overflow:hidden. Our setting like this allows browsers of IE6 and above to support the maximum width style, and also allows the hidden image under IE6 to exceed the width and expand the DIV. This method is more convenient and practical.

2). Only use the overflow:hidden attribute, as in method two

3) The image is processed by the software when uploading to adapt to the DIV layout width, as in method one

The above is the recommended method to solve the problem of IMG pictures breaking through the limited DIV width. According to the actual situation, you can choose the method that suits you to solve the problem of pictures breaking through the DIV layer in the web page.

1. Method 1 to prevent pictures from breaking the DIV - TOP



I tried overflow:hidden to no avail

The attributes I set for this DIV are
width:100%
height:100vh
The value in the background is cover

Will not burst in PC browser
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

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)

How to set up Google Chrome homepage How to set up Google Chrome homepage Mar 02, 2024 pm 04:04 PM

How to set up Google Chrome homepage? Google Chrome is the most popular web browser software today. This browser has simple and efficient features that users like. When using browsers, different people have different settings preferences. Some people like to use Google Chrome. The browser is set as the default homepage, and some people like to set the homepage as other search engines, so where should it be set? Next, the editor will bring you a quick method to set up the homepage of Google Chrome. I hope it can be helpful to you. How to quickly set the Google Chrome homepage 1. Open Google Chrome (as shown in the picture). 2. Click the menu button in the upper right corner of the interface (as shown in the picture). 3. Select the "Settings" option (as shown in the picture). 4. In the settings menu, find "Search Engine" (such as

How to crawl and process data by calling API interface in PHP project? How to crawl and process data by calling API interface in PHP project? Sep 05, 2023 am 08:41 AM

How to crawl and process data by calling API interface in PHP project? 1. Introduction In PHP projects, we often need to crawl data from other websites and process these data. Many websites provide API interfaces, and we can obtain data by calling these interfaces. This article will introduce how to use PHP to call the API interface to crawl and process data. 2. Obtain the URL and parameters of the API interface. Before starting, we need to obtain the URL of the target API interface and the required parameters.

Oracle API Usage Guide: Exploring Data Interface Technology Oracle API Usage Guide: Exploring Data Interface Technology Mar 07, 2024 am 11:12 AM

Oracle is a world-renowned database management system provider, and its API (Application Programming Interface) is a powerful tool that helps developers easily interact and integrate with Oracle databases. In this article, we will delve into the Oracle API usage guide, show readers how to utilize data interface technology during the development process, and provide specific code examples. 1.Oracle

How to deal with Laravel API error problems How to deal with Laravel API error problems Mar 06, 2024 pm 05:18 PM

Title: How to deal with Laravel API error problems, specific code examples are needed. When developing Laravel, API errors are often encountered. These errors may come from various reasons such as program code logic errors, database query problems, or external API request failures. How to handle these error reports is a key issue. This article will use specific code examples to demonstrate how to effectively handle Laravel API error reports. 1. Error handling in Laravel

Oracle API integration strategy analysis: achieving seamless communication between systems Oracle API integration strategy analysis: achieving seamless communication between systems Mar 07, 2024 pm 10:09 PM

OracleAPI integration strategy analysis: To achieve seamless communication between systems, specific code examples are required. In today's digital era, internal enterprise systems need to communicate with each other and share data, and OracleAPI is one of the important tools to help achieve seamless communication between systems. This article will start with the basic concepts and principles of OracleAPI, explore API integration strategies, and finally give specific code examples to help readers better understand and apply OracleAPI. 1. Basic Oracle API

React API Call Guide: How to interact and transfer data with the backend API React API Call Guide: How to interact and transfer data with the backend API Sep 26, 2023 am 10:19 AM

ReactAPI Call Guide: How to interact with and transfer data to the backend API Overview: In modern web development, interacting with and transferring data to the backend API is a common need. React, as a popular front-end framework, provides some powerful tools and features to simplify this process. This article will introduce how to use React to call the backend API, including basic GET and POST requests, and provide specific code examples. Install the required dependencies: First, make sure Axi is installed in the project

Development suggestions: How to use the ThinkPHP framework for API development Development suggestions: How to use the ThinkPHP framework for API development Nov 22, 2023 pm 05:18 PM

Development suggestions: How to use the ThinkPHP framework for API development. With the continuous development of the Internet, the importance of API (Application Programming Interface) has become increasingly prominent. API is a bridge for communication between different applications. It can realize data sharing, function calling and other operations, and provides developers with a relatively simple and fast development method. As an excellent PHP development framework, the ThinkPHP framework is efficient, scalable and easy to use.

Save API data to CSV format using Python Save API data to CSV format using Python Aug 31, 2023 pm 09:09 PM

In the world of data-driven applications and analytics, APIs (Application Programming Interfaces) play a vital role in retrieving data from various sources. When working with API data, you often need to store the data in a format that is easy to access and manipulate. One such format is CSV (Comma Separated Values), which allows tabular data to be organized and stored efficiently. This article will explore the process of saving API data to CSV format using the powerful programming language Python. By following the steps outlined in this guide, we will learn how to retrieve data from the API, extract relevant information, and store it in a CSV file for further analysis and processing. Let’s dive into the world of API data processing with Python and unlock the potential of the CSV format

See all articles