Skip to main content

Properties with Colors and Backgrounds in CSS

Foreground color: the 'color' property
The color property describes the foreground color of an element.
Sample code is given below copy and try it out...
 
 h1 {
  color: #990099;
 }
 h3{
  color: #999999;
 }
 p {
  color: #990099;
 }
'background-color' property
The background-color property describes the background color of elements.
Sample code is given below copy and try it out...
 
 h1 {
  background-color: #990099;
 }
 h3{
  background-color: #999999;
 }
 p {
  background-color: #990099;
 }
Background images [background-image]
The CSS property background-image is used to insert a background image.
Sample code is given below copy and try it out...
 

body {
 background-color: #FFCC66;
 background-image: url("016.jpg");
     }
Repeat background image [background-repeat]
This property describes whether background image has to repeat or not,because if given by default it will repeat horizontally.
background-repeat: repeat - image will be repeated both horizontally and vertically
background-repeat: repeat-x - image will be repeated both horizontally
background-repeat: repeat-y - image will be repeated both vertically
background-repeat: no-repeat - image will not repeat
Sample code is given below copy and try it out...
 
body {
 background-color: #FFCC66;
 background-image: url("8701.gif");
 background-repeat: repeat
 /*background-repeat: repeat-x*/
 /*background-repeat: repeat-y*/
 /*background-repeat: no-repeat*/
     }
Lock background image [background-attachment]
The property background-attachment specifies whether a background picture is fixed or scrolls along with the containing element.
Background-attachment: scroll - The image scrolls with the page - unlocked
Background-attachment: fixed - The image is locked
 
body {
 background-color: #FFCC66;
 background-image: url("8701.gif");
 background-repeat: repeat
 background-attachment: fixed;
 /*background-attachment: scroll;*/
 }
Place background image [background-position]
This property will help you to change the default position of image and we can set image in a fixed position.
background-position: 3cm 3cm - The image is positioned 3 cm from the left and 3 cm down the page
background-position: 50% 25% - The image is centrally positioned and one fourth down the page
background-position: top right - The image is positioned in the top-right corner of the page
 
 body {
 background-color: #FFCC66;
 background-image: url("8701.gif");
 background-repeat: no-repeat;
 background-attachment: fixed;
 background-position: right bottom;
      }
Compiling [background]
From the above example we saw that we used different background properties together,we can compile these properties to a single unit and develop a single line of code.
for example the above codecan be rewritten as source code gven below :
 
background: #FFCC66 url("8701.gif") no-repeat fixed right bottom;
If a property is left out, it will automatically be set to its default value.

Comments

Popular posts from this blog

Spannable String in Android - URL Span ,Clickable Span, Rich-Style Formatting of Textview .....

See more Android Tutorials here....... Faster Loading images in GridViews or ListViews Spannable brings lots of possibility to TextView, includes displaying various appearance of a Text and onClick callbak. The SpannableString class allows you to easily format certain pieces which are called spans of a string, by applying CharacterStyle ie,color, font, ormake it a link . Here is an example where, explained how to use spannable string to give font size, color, linking a text via clickable span and through URL Span and to strike through the text. Lets go through the example : import android.os.Bundle; import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; import android.text.style.StrikethroughSpan; import android.text.style.URLSpan; import android.view.View; import android.widget.TextView; import android.widget.Toast; ...

Use Your Own SQLite in ANDROID Application or Using 'SQLite Asset Helper' to read your own databases stored in Asset folder

See more basics on Android along with interview questions See SQLite tutorial here If you want to read your own databases in ANDROID APPLICATION, this post may help you. You may be familiar by creating SQLite in Android use  SQLiteOpenHelper . Here we are going to deal with using our own databases.  I have a database named 'mydatabase.sqlite', which consist of a set of name and age of 5 students. Suppose I want to view the database, I can use SQLite database browser which you can download from here.                                                     download browser..... Through this browser we can view the databases, can even modify delete or create a new one. 'mydatabase.sqlite' with name and age of five students is browsed and viewed as shown below Now  make a zip format of database and copy this database to asse...

Passing Images between Activities in Android

in First Activity: Intent intent=new Intent(FirstClass.this, SecondClass.class); Bundle bundle=new Bundle(); bundle.putInt("image",R.drawable.ic_launcher); intent.putExtras(bundle); startActivity(intent); in Second Acticity: Bundle bundle=this.getIntent().getExtras(); int pic=bundle.getInt("image"); v.setImageResource(pic); another method: in First Activity: Drawable drawable=imgv.getDrawable(); Bitmap bitmap= ((BitmapDrawable)drawable).getBitmap(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] b = baos.toByteArray(); Intent intent=new Intent(Passimage.this,myclass.class); intent.putExtra("picture", b); startActivity(intent); in Second Acticity: Bundle extras = getIntent().getExtras(); byte[] b = extras.getByteArray("picture"); Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.lengt...