Home > Web Front-end > JS Tutorial > js uses the div background to create a vertical line effect. _javascript skills

js uses the div background to create a vertical line effect. _javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:58:20
Original
1419 people have browsed it

Later I found that if the div style is set to a specific height, it can behave normally regardless of IE or FF.

But this height is not fixed, but will change depending on the content of the adjacent div. In the end, I had to use JavaScript to capture the height of the relevant div when loading, assign it to the specified div style, and finally see what I wanted.

The specific script is as follows:

window.onload=function(){
document.getElementById('bg').style.height=document.getElementById('mydiv') .offsetHeight 'px';
}

"bg" is the div whose height you want to change, and "mydiv" is the div you want to refer to.

The last unit "px" must be added, otherwise it will not be recognized under ff.

There is still a problem. I saw someone said that the offsetHeight attribute is no longer supported in IE7. I have not tried it specifically. If this is the case, it will have to be blank under IE7.

Related labels:
source:php.cn
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template