Solved

How do I create a global CSS statement for all input fields on all my .aspx pages

Posted on 2010-09-17
5
328 Views
Last Modified: 2012-05-10
Is there a way to define a global style that will cover all the input elements throughout my site? I don't want to have to assign the style to each element (ie cssClass=).

Something like: BODY {font-family: serif; background-color: silver;}  only to cover asp:textbox, asp:dropdownlist, etc.

tried INPUT.TEXT{ }.... this doesn't work

Thanks
0
Comment
Question by:Bob Hoffman
5 Comments
 
LVL 9

Expert Comment

by:TonyReba
ID: 33705905
if you dont want to use a class,

input[type=button], input[type=submit]
{
width:auto;
padding:3px 6px;
color:#ffffff;
text-align:center;
background:#e2212a;
font-size:11px;
font-weight:bold;
border:0px;
margin:2px;
cursor:pointer;
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;

}

Open in new window

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33705909
0
 
LVL 9

Accepted Solution

by:
TonyReba earned 500 total points
ID: 33705920
this goes in your head secition
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>-z-</title>
<style type="text/css">
input, textarea {
border: 2px solid #d69;
background: #999;
float: left;
clear: left;
width: 250px;
margin: 10px 0;
padding: 6px;
font: 1.2em monospace;
color: #fc3;
letter-spacing: .07em;
}
</style>
</head>

Open in new window

0
 
LVL 1

Expert Comment

by:Hafeez Ansari
ID: 33708630
You can do it in 2 different ways, first method is to write css codes direct for input elements e.g.

input[type=text]
{
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding:4px;
font:12px;
}
in the above mentioned codes you are writing codes to apply directly on input type. and wherever you'll use in html <input type="text"............. /> these codes will automatically apply to all inputs.
But you can do the same thing in another way, first write a style class and then apply to the concerning elements e.g.
.textEntry
{
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding:4px;
font:12px;
}
now you have a class named 'textEntry' in your css and you can apply this class to the elements for example:
<input class="textEntry" type="text size="25" value="" />

hope this will be helpful to you.
0
 
LVL 8

Author Closing Comment

by:Bob Hoffman
ID: 33711550
This did the trick... added "select" to handle the dropdown lists.

input, textarea, select {}

Thanks everyone.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now