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
What attribute makes a radio button or checkbox input selected?
checked="checked" selected="selected" disabled="disabled"
<input type="checkbox" name="a_name" value="value" checked="checked" />
What CSS value scales the background image to the largest size contained within the element?
repeat-x contain linear-gradient
#id {
  background:url("path_to_image.png");
  background-size:contain;
  background-repeat:no-repeat;
}
What operator is used to determine the rest of the division of two numbers?
% * /
var rest8_7 = 8 % 7;
alert(rest8_7);
Indicate the PHP function that rounds a number up to the next highest integer.
floor() ceil() abs()
$nr = ceil(3.5);
echo $nr;        // 4
CSS cursor property - Custom Cursors

Last accessed pages

  1. PHP MySQL - SELECT, ORDER BY (12777)
  2. The Prayer of the Frog (2055)
  3. dompdf (3819)
  4. Follow the mouse cursor with a DIV inside a Parent (8303)
  5. CSS Outline (2573)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (18)
  2. SSEP - Site Search Engine PHP-Ajax (8)
  3. Read Excel file data in PHP - PhpExcelReader (7)
  4. The Mastery of Love (6)
  5. Get Duration of Audio /Video file before Upload (6)
Chat
Chat or leave a message for the other users
Full screenInchide