div如何自适应宽度_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:35:31
Original
1035 people have browsed it

<div id="main"><div style="width:200px;float:left;background:#f00;">固定宽度<div><div style="float:left;background:#ff0;">要如何让这个div的宽度自由随着main的宽度自动变化呢</div></div><table width=100%><tr><td width=200>用table就可能很方便实现</td><td>用div要怎么做呢</td></tr></table>
Copy after login


特注: 不能用js来实现


回复讨论(解决方案)

为什么就没人回复个呢

固定宽度

要如何让这个div的宽度自由随着main的宽度自动变化呢

<div id="main"><div style="width:200px;float:left;background:#f00;">固定宽度<div><div style="float:left;background:#ff0;width:100%">要如何让这个div的宽度自由随着main的宽度自动变化呢</div></div>
Copy after login

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">.div1{background:#f00;width:200px;float:left;}.div2{background:#ff0;margin-left:200px;}</style></head><body><div id="main"><div class="div1">固定宽度</div><div class="div2">要如何让这个div的宽度自由随着main的宽度自动变化呢</div></div></body></html>
Copy after login

设置宽度时候用百分比就行了

Copy after login

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档





    

         左边固定大小
        

        

右边根据 main 自动适应大小


    



这个方法 使用大多数浏览器,我开始也在找才看到你的帖子,着了好久都没有结果,然后就自己试咯。最好觉得就这个挺合理的,我的QQ280026181 如果有需要可以加我。我也经常遇到类似问题可以相互请教

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template