Css Course


The cursor property can be used to change and control the appearance of the mouse cursor.
Syntax:

selector { cursor: value; }
- value - specifies the type of cursor to be displayed when pointing on an elemen.
In this table there are diferent types of values that you can use for cursor property (bellow you can see some code examples):

CSS Cursors
Example, three DIVs with diferent cursor type for each one.
<style>
#ex1 div {
 display: inline-block;
 width: 28%;
 height: 75px;
 margin: 2px 1%;
 background: #d0d0fe;
 text-align: center;
}
#idiv1 { cursor: pointer; }
#idiv2 { cursor: wait; }
#idiv3 { cursor: move; }
</style>

<h4>Example CSS cursor property</h4>
<p>Move the mouse over each cell.</p>

<div id='ex1'>
 <div id='idiv1'>Value - pointer</div>
 <div id='idiv2'>Value - wait</div>
 <div id='idiv3'>Value - move</div>
 <br style='clear:left;' />
</div>

Cursor Images

If you want a custom cursor, you can use an image for the mouse cursor appearance. The standard image type that can be used for cursor is the .cur format.
To create a .cur file, you need specialized imagery software. A freely available cursor editor is the JustCursors, you can use this software to edit /create static or animated cursors. To download it, click: Download JustCursors.
Once you have the '.cur' file, use this syntax in your style sheet:
selector { cursor: url('image.cur'), default; }

Example:
<style>
#ex2 {
 height: 100px;
 background: #fefeae;
 cursor: url('css/bluearrow.cur'), default;
}
</style>

<h4>Example image cursor</h4>
<p>Place your mouse over the text bellow.</p>

<div id='ex2'>Cursor Image, '.cur'</div>

Modern browsers, like Mozilla Firefox, Google Chrome, can use PNG images for cursor.


- Another example, cursor with PNG image (a cursor rose):
<style>
#ex3 {
 height: 100px;
 background: #fefeae;
 cursor: url('css/rosecursor.png'), default;
}
</style>

<h4>Example PNG image cursor</h4>
<p>Place your mouse over the text bellow.</p>

<div id='ex3'>Cursor Images, '.png' (for modern browsers).</div>

Click: Cursor Images to download an archive with some '.cur' and '.ani' files that you can use to test the examples presented in this tutorial.


Path to the image file

If you add the CSS code into an external '.css' file, take into account the fact that modern browsers (Mozilla Firefox, Google Chrome) interpret relative URLs as relative to the '.css' file. So, in the code in '.css' add the 'url' paths for '.cur' file, relative to that '.css' file.
/*
 The CUR and CSS files are in the same folder, the HTML is in a directory above this CSS file
*/

#id {
 cursor: url('bluearrow.cur'), default;
}

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which attribute is used in <a> tag for the address of the link?
src href rel
<a href="http://coursesweb.net/" title="CoursesWeb.net">CoursesWeb.net</a>
Which CSS property sets the type of the text font?
font-family text-decoration font-size
h2 {
  font-family:"Calibri",sans-serif;
}
What instruction selects all the <div> tags with class="cls"?
querySelector("div.cls") getElementsByTagName("div") querySelectorAll("div.cls")
var elm_list = document.querySelectorAll("div.cls");
var nr_elms = elm_list.length;       // number of selected items
alert(nr_elms);
Indicate the function that can be used to get the sum of values in an array.
array_sum() array_diff() array_shift()
$arr =[1, 2, 3, 4);
$arr_sum = array_sum($arr);
echo $arr_sum;       // 10
CSS cursor property - Custom Cursors

Last accessed pages

  1. Learning Vue.js - Tutorials (1049)
  2. Objects in 3D Space (2035)
  3. Star shapes with CSS (11300)
  4. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (143446)
  5. Callback Functions in JavaScript (1140)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (679)
  2. CSS cursor property - Custom Cursors (87)
  3. Read Excel file data in PHP - PhpExcelReader (59)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (58)
  5. The Mastery of Love (57)