最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Resize pre element by dragging - Stack Overflow

programmeradmin2浏览0评论

I'd like the user to resize the pre elements in my AngularJS page by dragging the bottom border. The effect I aim to achieve is a very similar way to the way the textarea I am using now stackoverflow, but only to read the text written in the pre more effectively.

This is the simple piece of AngularJS code

<div class="container">
    <div class="jumbotron">
        <div class="row">
            <div class="col-md-6">
                First variable
                <pre>{{first}}</pre>
            </div>
            <div class="col-md-6">
                Second variable
                <pre>{{second}}</pre>
            </div>
        </div>
    </div>
</div>

The css bit associated with the pre is the following

pre {
  tab-size: 2;
  text-align : left;
  height: auto;
  max-height: 240px;
  overflow: auto;
  word-break: normal !important;
  word-wrap: normal !important;
  white-space: pre !important;
};

What I would like to have is to be able to resize the height of either pre to show more content.

I took a look at this example thinking that I can maybe work on resizing the divs containing the pre. Unfortunately I cannot make it work, but I am not even sure that was the right way.

I'd like the user to resize the pre elements in my AngularJS page by dragging the bottom border. The effect I aim to achieve is a very similar way to the way the textarea I am using now stackoverflow, but only to read the text written in the pre more effectively.

This is the simple piece of AngularJS code

<div class="container">
    <div class="jumbotron">
        <div class="row">
            <div class="col-md-6">
                First variable
                <pre>{{first}}</pre>
            </div>
            <div class="col-md-6">
                Second variable
                <pre>{{second}}</pre>
            </div>
        </div>
    </div>
</div>

The css bit associated with the pre is the following

pre {
  tab-size: 2;
  text-align : left;
  height: auto;
  max-height: 240px;
  overflow: auto;
  word-break: normal !important;
  word-wrap: normal !important;
  white-space: pre !important;
};

What I would like to have is to be able to resize the height of either pre to show more content.

I took a look at this example thinking that I can maybe work on resizing the divs containing the pre. Unfortunately I cannot make it work, but I am not even sure that was the right way.

Share Improve this question asked Aug 12, 2015 at 14:13 user1472709user1472709 1333 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Give the pre these rules:

pre {
  resize: both;
  overflow: auto;
}

Snippet

pre {
  resize: both;
  overflow: auto;
  height: 70px;
  width: 150px;
}
<pre>#include "me.h";
#include "conio.h";</pre>

发布评论

评论列表(0)

  1. 暂无评论