关于CSS样式的引用_html/css_WEB-ITnose
很多时候,在布局中需要统一样式,又不可能挨个修改,于是就用到了CSS的统一样式。
写一个公用的样式,需要的东东一起调用。如果需要修改样式,则只需要修改该公用样式即可。
下面简单说一下创建并引用CSS样式的几个进本步骤:
1、现在工程的WebContent目录下创建一个新文件夹,命名为style(这个随意)。
表明我们这个文件夹里放的是CSS样式文件。
2、在刚刚创建的style文件夹内右键-New-Other选择创建CSS文件,并命名。我这里命名为mystyle.css.
3、在这个css样式文件中自定义一个样式。
.pp { size: 24em; color: red;}
我是这样定义的,可以定义为你想要的样式。
4、引用说明
引用分为两个部分
一个是在JSP文件中引用,另一个是在Html文件中引用,两个稍微有点不同。
在JSP文件中引用:
<head> <link href="${pageContext.request.contextPath}/style/mystyle.css" rel="stylesheet"></head>
在Html文件中引用:
<head> <meta charset="UTF-8"> <link href="style/mystyle.css" rel="stylesheet"></head>
通过对比可以发现不同点在${pageContext.request.contextPath}关于工程的路径上
5、开始引用(JSP、Html这两个是相同的)
<form name="myForm" action="/WebTest001/myServlet" method="post"> <p class="pp">这个是CSS练习</p> <input class="pp" type="button" value="send" onclick="send();"></form>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.
