简体   繁体   English

扩展div以显示隐藏的内部内容

[英]Expanding div to show hidden inner content

I'm new to Angular, and rusty with HTML and CSS, so I was wondering how I could create a "write post" text area (similar to facebook or medium.com), whereby the user is first presented with a small "write here" box, and then when they click on the writing area, the div expands, and then new controls are shown. 我是Angular的新手,并且对HTML和CSS感到生疏,所以我想知道如何创建“写帖子”文本区域(类似于facebook或medium.com),从而首先向用户显示一个小的“写”此处”框,然后当他们单击书写区域时,div会展开,然后显示新的控件。 I've added some screen shots below to help explain what I mean. 我在下面添加了一些屏幕截图,以帮助解释我的意思。

I understand how to expand divs and do DOM manipulation through Angular via directives, but I'm just wondering how I should approach this problem at a higher level. 我知道如何通过指令通过Angular扩展div和进行DOM操作,但是我只是想知道如何在更高层次上解决此问题。

原始状态

then the user clicks on the above, and the div expands, and inner content is shown: 然后用户单击以上内容,然后div扩展,并显示内部内容:

用户单击书写区域后

I have the below in my index.ejs: 我的index.ejs中包含以下内容:

    <div write-post-box id="write_post_box">
        <p>Write here...</p>
    </div>

and the below directive in my angular file: 和我的角度文件中的以下指令:

app.directive('writePostBox', function() {
    return {
    link: function(scope, element, attrs){
        element.click(function() {
            element.css('height', '200px');
        });
    }
    };
});

您可以使用ngFocusngBlur指令( 检查它们) ,然后从这些函数中设置textarea / div高度。

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

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