Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Rounded Edges For Textarea With Css, CSS way of formatting elements
rvovk
post Aug 7 2005, 09:54 AM
Post #1


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



Today's tutorial is meant for spicing up graphical looks of textarea in our websites. Instead of plain squared edges we will gain rounded edges. Result of this tutorial will look like this:

user posted image

So let begin with CSS file. First we will define body:

CODE
body{
width:100%;
 margin:0;
 padding:0;
 text-align:center;
background:#FFFFFF;
}


We have choosen that our body background will be white (#FFFFFF). Cause we will be using rounded corners for our textarea with background color bright blue (#B4D5ED). Rounded corner's images are:

Topleft user posted image
Topright user posted image
Bottomright user posted image
Bottomleft user posted image

We will embed then into our textarea, next pictures is showing us how it is done:

user posted image

It is like pilling onion. In HTML. If we look at text which is defined with class TEXT which is relativly looking at the top, then we have class TOPLEFT, TOPRIGHT, BOTTOMRIGHT and BOTTOMLEFT which are in sequence from topleft clockwised to bottomright, at the bottom lies class TEXTAREA which is cover with other classes and being formatted that way.

user posted image

So documents starts rendering with BODY and goes towards up to last class, which is TEXT and all classes (or ID) are closed with </div>. I see this as pyramidal structure.

So HTML file looks like this:

CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<link rel="shortcut icon" href="slike/favicon.ico" type="image/x-icon">

<title>Rounded edges for textarea with CSS.</title>
<meta http-equiv="content-type" content="text/html;charset=windows-1250">
<style type="text/css" media="all">@import "layout1.css";</style>

</head>

<body>

<div class="textarea">
<div class="topleft">
<div class="topright">
<div class="bottomright">
<div class="bottomleft">
<p class="text">Things in the future have changed dramatically. I bought Canon A40 in year 2002 and took several interesting pictures with it. Later I bought Sony DSC S-75 cause I liked its macro potencial. But I sold it quickly cause it had lot of noise in images and awful white balance. Just before end of year 2003 I bought myself second hand Canon G3 which I am still using. Canon G3 is very good prosumer camera with pleasant results.</p>
</div><!--bottomleft-->
</div><!--bottomright-->
</div><!--topright-->
</div><!--topleft-->
</div><!--textarea-->

</body>
</html>


Textarea is defined in CSS with next code. There is no padding (if there was any then your background would be corrupted). Background is set to #B4D5ED and width to 300px.

CODE
.textarea{
margin:10px auto 0 auto;
padding:0;
width:300px;
background:#B4D5ED;}


Div classes for rounded edges are name with TOPLEFT, TOPRIGHT, BOTTOMRIGHT, BOTTOMLEFT. They are almost same code, so I will explain only one.

So here is code for all divclasses of rounded edges. As we saw at beggining we have background images that are named same as div classes. Margin and padding is set to 0, cause we don't wanna have corrupted background, url is defining relative path to your background image. Position is declared for class TOPLEFT with code: top left no-repeat. This defines topleft positon and no-repeat, cause we wanna for every image to be presented only once. Same goes for other div classes, only position is changes and name of image file.

CODE
.topleft{
margin:0;
padding:0;
background:url(topleft.jpg) top left no-repeat;}

.topright{
margin:0;
padding:0;
background:url(topright.jpg) top right no-repeat;}

.bottomright{
margin:0;
padding:0;
background:url(bottomright.jpg) bottom right no-repeat;}

.bottomleft{
margin:0;
padding:0;
background:url(bottomleft.jpg) bottom left no-repeat;}


Code for text is next. This rather formatting of text, important thing is that we used padding of 10px to have same space around text.

CODE
p.text{
 font:12px/16px verdana, arial, serif;
color: #000000;
margin:0;
padding:10px;
text-align:justify; }


Working example is available: here.
CSS file is available: here.

Any suggestions are welcome.
Best regards.


Go to the top of the page
 
+Quote Post
Adamrosso
post Aug 7 2005, 11:06 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 128
Joined: 6-August 05
Member No.: 10,402



Nice tutorial. I see you are pretty good with CSS. Funny how i was looking for a tutorial like this. Anyway, thank you. 10/10
Go to the top of the page
 
+Quote Post
cragllo
post Aug 7 2005, 11:53 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 933
Joined: 24-August 04
Member No.: 892



When I read this i thought you mean input textarea, But anyway, awesome tutorial, plain and simple, easy to follow.
Go to the top of the page
 
+Quote Post
rvovk
post Aug 7 2005, 12:06 PM
Post #4


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



With small workflow it can be used for input textarea too.
Go to the top of the page
 
+Quote Post
Tyssen
post Aug 7 2005, 12:42 PM
Post #5



***********

Group: Members
Posts: 1,161
Joined: 9-May 05
From: Brisbane, QLD
Member No.: 6,818



Not trying to rain on your parade, but you can accomplish the same effect through CSS without images.
Go to the top of the page
 
+Quote Post
rvovk
post Aug 7 2005, 12:57 PM
Post #6


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



Dammit, Tyssen. I am always two steps behind you laugh.gif
I wonder how would you make shadows without images tongue.gif
Thanx for link, It was educational.
Go to the top of the page
 
+Quote Post
cragllo
post Aug 7 2005, 01:03 PM
Post #7


Privileged Member
*********

Group: Members
Posts: 933
Joined: 24-August 04
Member No.: 892



Shadows are easy, use layers.... one dark, one light....
Go to the top of the page
 
+Quote Post
truefusion
post Aug 7 2005, 01:44 PM
Post #8


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,918
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528



QUOTE(rvovk @ Aug 7 2005, 08:57 AM)
I wonder how would you make shadows without images  tongue.gif

Filters, for example:

CODE

<style>
.DS{
filter: dropshadow(color=black, offx=1, offy=1, positive=1);
height: 9
}


This may only work for IE. For some reason it wont work without the height property.
Go to the top of the page
 
+Quote Post
Sprnknwn
post Aug 7 2005, 05:34 PM
Post #9


Privileged Member
*********

Group: Members
Posts: 821
Joined: 6-March 05
Member No.: 4,202