Home > Sci-Tech
Build Node.js Chat room web application: use Bootstrap chat room UI
2022-05-14 18:07:47 17 ℃Bootstrap is a popular HTML and CSS framework for building websites and web applications. It is the first project on Github. Bootstrap supports the response web design, allowing your page layout to adapt to the device (desktop, tablet, mobile device).
To add Bootstrap to our project, we must download the reduced CSS and JS files for Bootstrap. You can download Bootstrap from this link. After downloading bootstrap, unzip the file and copy the folder to the folder CSS in the project. jsfontspublic
You will notice some inconsistent with the structure of the existing folder. We will uniform style tables and JavaScript folders. CSS I prefer the Bootstrap naming method of Forshlesheets and JSFOR. JavaScript is shared with other third -party libraries because of it. Copy files to styleSheets to CSS and delete the JavaScript folder because it should be empty. Next, go to layout.jade and change the following:
Link (REL = 'STYLESHEET' Href = '/Stylesheets/Style.css')
arrive:
Link (REL = 'STYLESHEET' Href = '/CSS/Style.css')
Next, we want to add the Bootstrap CSS file to the title and the appropriate meta marker Layout.jade of the HTML5 application in the file. Style.css you must add a deale before the line containing links.
Meta (Charset = "UTF-8") Meta (http-equiv = "x-ua-compatible" content = "ie = edge") link (rel = 'styleSheet' href = '/css/bootstrap.min .css') Link (REL = 'STYLESHEET' Href = '/CSS/BOOTSTRAP- TheME.MIN.CSS')
Next, we want to add the JavaScript file required for Bootstrap and the plug -in. Layout.jade at the end of the following travel:
Script (type = 'text/javascript' src = '/js/bootstrap.min.js')
Doctype htmlhtmlHetmlHetti = titlemeta (charset = "utf-8") = "X-ua-compatible" content = "ie = edge") link (rel = 'styleSheet' href = '/css/bootstrap.min.css') link (rel = 'styleSheet'/css/bootstrap -Theme.min.css') link (rel = 'styleSheet' href = '/css/style.css') BodyBlock ContentScript (type =' text/javascript 'src ='/js/bootstrap.min.js') /code>
It's time to develop a chat user interface layout. First, you may want to know Bootstrap and check this long tutorial. All chat engines have a area used for recently received and a area for users to write and send messages. Historically, the layout is to add the editing area to the bottom and add the message to the top.
If you do not do some jobs, it is not easy to fix the elements on the HTML page to the bottom of the viewport. I will fix my foot to the bottom according to this example. We want to modify the index.jade file and delete all code lines under the content block.
First, we add the page area that will receive a message. Let's start wrap from adding a div. In jade, you just need to write a
Next, we want to add another DIV class Container-Fluid to add fluid width to the page. Inside, I will create a H1 element with "Welcome to the Node Chat Room" and a DIV with IDMESSAGES and FinalDIV. At the bottom of the mouth. .wrap.container-Fluidh1 Welcome to the Node Chatroom#Messages.push
Next, we will develop a message editing area. We want to capture the text box and send buttons Container-Fluid in the call and div in the DIV. Footer div with the same shrinking into the Wrap Div.
Next, I will use the Bootstrap grid system (understand it here) to divide the message editing area into two. One column will occupy most of the space and will include a text box for writing messages. The second column will contain a button that contains Block-level to send messages. Paragraph please note how Jade allows us to use the attributes of the symbol specified element. The code will be shown below:
.footer.Container-fluid.Row.Col-XS-8.Col-SM-9INPut (type = "text" id = "message-box" class = "form-control input-lg" plalder = "write a message here ... "ROWS =" 3 "). COL-XS-4.COL-SM-3Button#Send-Message-BTN.BTN.BTN-LG.BTN-BLOCK Send Message
Extends LayoutBlock Content.wrap.container-Fluidh1 Welcome to the Node Chatroom#Messages.push.footer.Containerow.Row-XS-SM-SM-9ine. "MESSAGE-BOX" class = "Form-Control input-Lg" Placeholder = "Write A Message Here ..." ROWS = "3"). Col-Xs-4.Col-SM-3Button#Send-Message-BTN .btn.btn-primary.btn-lg.btn-black send message
We hope to force the message editing area to the bottom of the viewport. We will hope to add some custom CSS rules on the Public/CSS/Style.styl page. This file uses the Stylus CSS preprocessor, but you can also paste the CSS with verbatim. These CSS will be re -copied to the generated CSS file.
First, we must ensure that the entire page occupies a height of 100%.
HTML, Bodyheigh: 100%
Secondly, we must ensure that the change area occupies the largest height, but leaves a 60px border for the foot and message editing area at the bottom.
.wrapmin -height: 100%Height: Auto! Importantheight: 100%Margin: 0 Auto -60px
>
Third, we must ensure that this space in the editing area is respected and assigned it to the footer.
.push, .footerheight: 60px
Finally, for stylistic reasons, let us add a delicate background color to the footer.
.footerBackground-COLOR: **#F5F5F5 **
html, bodyheight: 100%.wrapmin-height: 100%Height: Importantheight: 100%MARGIN: 0 Auto -60 , .footerheight: 60px.footerBackground-COLOR: #F5F5F5
- In the previous:What should I do if I cannot shut down Win11?Win11 cannot be shut down solution
- The next article:Will the big data major seem tall?
Guess you like
- 2022-07-05After Chinese enterprises decreased by 24 billion chips, the Meixin factory was anxious?Foreign media: Can't change anymore
- 2022-07-05His wife was lost after the actual control, and Wei Ya couldn't save the sad home spinning boss
- 2022-07-05Can Huawei become a car circle of Laicha?
- 2022-07-05Huayi Tencent Entertainment (0419.HK): bet 4 trillion gold tracks, transform Internet medical care
- 2022-07-05Come and watch, 17 practical skills of operation and maintenance, collect it at any time ~
- 2022-07-05Qidelon science: automatic production technology for high -quality materials to achieve high -quality materials with refractory materials
- 2022-07-05Experience AITO asking industry M7 | Definition of millions of luxury cars is a compulsory course for contemporary CEOs
- 2022-07-05This iPhone13pm little white does not buy!Expansion machine, over -guaranteed, no activation date, black machine
- 2022-07-05The second impact!Why is it full of controversy?
- 2022-07-04Xiaomi 12SPRO Tiandai version is on the road: compared to the Snapdragon version, I still persuade everyone to consider carefully
- Southern Bolun A Investment Establishment of Smart Equipment Manufacturing Company
- His wife was lost after the actual control, and Wei Ya couldn't save the sad home spinning boss
- 2022176 Issue 3D Breaking Group Challenge
- 10 points to improve the click -through rate of micro -head strips, use it if you learn it.
- Come and watch, 17 practical skills of operation and maintenance, collect it at any time ~
- Starting from 319,800 yuan, the second model of the AITO brand asked M7
- Natural sub -magazine: ultra -fast laser for detecting the next generation of solar cells
- Starting from 319,800 yuan, Yu Chengdong said that "comfort is more than one million luxury cars". Ask the M7 to "positive" with the ideal one?
- Why do I have fingerprint locks now, and the criminals can still crack quickly?what way?
- Huawei Application Market announced that the two types of application apps are no longer included