简体   繁体   English

让 div 向右展开?

[英]Make a div expand to right?

Is there any way to make a div expand to right with css when content added to it with ajax?当使用 ajax 将内容添加到其中时,有什么方法可以使用 css 使 div 向右扩展? Or should i use javascript for this job?还是我应该使用 javascript 来完成这项工作?

Also parent container has a width set, but also has overflow:auto.父容器也设置了宽度,但也有溢出:自动。 Sorry for late edit抱歉编辑晚了

Since you're using JS to retrieve/add content via AJAX, you could have the JS code add/modify the class on the <div> as well.由于您使用 JS 通过 AJAX 检索/添加内容,因此您也可以让 JS 代码在<div>上添加/修改 class。 Then you can control it with CSS.然后你可以用 CSS 来控制它。

$("#mydiv").animate({
    width += 'xxx'
},5000);

You may want your width value to scale with the length of your response.您可能希望您的宽度值与您的响应长度成比例。 Perhaps create a multiplier.也许创造一个乘数。

AJAX is a technology not a scripting/programming language. AJAX是一种技术,而不是脚本/编程语言。

Use JavaScript:)使用 JavaScript :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM