Home >Web Front-end >HTML Tutorial >css div的宽度随内部元素的宽度的变化而变化_html/css_WEB-ITnose

css div的宽度随内部元素的宽度的变化而变化_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:04:121962browse

div是块级元素,如果不设置他的明确的宽度,那他就等于父元素的宽度,如果要让其它随着子元素的变化而变化,需要改变他的属性,给他加上这个css属性即可display:inline-block

或干脆把div直接替换为span解决一切问题

Statement:
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