सीएसएस लिंक
CSS के साथ, लिंक्स को कई अलग-अलग तरीकों से स्टाइल किया जा सकता है।
टेक्स्ट लिंक टेक्स्ट लिंक लिंक बटन लिंक बटन
स्टाइलिंग लिंक
लिंक को किसी भी CSS संपत्ति (जैसे color
, font-family
,
background
, आदि) के साथ स्टाइल किया जा सकता है।
उदाहरण
a {
color: hotpink;
}
इसके अलावा, लिंक को अलग-अलग स्टाइल किया जा सकता है, जो इस बात पर निर्भर करता है कि वे किस स्थिति में हैं।
चार लिंक राज्य हैं:
a:link
- एक सामान्य, अनजान लिंकa:visited
- एक लिंक जिसे उपयोगकर्ता ने देखा हैa:hover
- एक लिंक जब उपयोगकर्ता इस पर माउस ले जाता हैa:active
- एक लिंक जिस क्षण इसे क्लिक किया जाता है
उदाहरण
/* unvisited link */
a:link {
color: red;
}
/* visited
link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
कई लिंक राज्यों के लिए शैली सेट करते समय, कुछ आदेश नियम होते हैं:
- ए: होवर को ए: लिंक के बाद आना चाहिए और ए: विज़िट किया जाना चाहिए
- ए: सक्रिय एक के बाद आना चाहिए: होवर
पाठ सजावट
संपत्ति का text-decoration
उपयोग ज्यादातर लिंक से रेखांकन हटाने के लिए किया जाता है:
उदाहरण
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
पृष्ठभूमि का रंग
background-color
लिंक के लिए पृष्ठभूमि रंग निर्दिष्ट करने के लिए संपत्ति का उपयोग किया जा सकता है :
उदाहरण
a:link {
background-color: yellow;
}
a:visited {
background-color: cyan;
}
a:hover {
background-color: lightgreen;
}
a:active {
background-color: hotpink;
}
लिंक बटन
यह उदाहरण एक अधिक उन्नत उदाहरण प्रदर्शित करता है जहां हम लिंक को बॉक्स/बटन के रूप में प्रदर्शित करने के लिए कई सीएसएस गुणों को जोड़ते हैं:
उदाहरण
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
और ज्यादा उदाहरण
उदाहरण
यह उदाहरण दर्शाता है कि हाइपरलिंक में अन्य शैलियों को कैसे जोड़ा जाए:
a.one:link {color: #ff0000;}
a.one:visited {color: #0000ff;}
a.one:hover
{color: #ffcc00;}
a.two:link {color: #ff0000;}
a.two:visited {color:
#0000ff;}
a.two:hover {font-size: 150%;}
a.three:link {color:
#ff0000;}
a.three:visited {color: #0000ff;}
a.three:hover {background:
#66ff66;}
a.four:link {color: #ff0000;}
a.four:visited {color:
#0000ff;}
a.four:hover {font-family: monospace;}
a.five:link {color:
#ff0000; text-decoration: none;}
a.five:visited {color: #0000ff;
text-decoration: none;}
a.five:hover {text-decoration: underline;}
उदाहरण
लिंक बॉक्स/बटन बनाने का दूसरा उदाहरण:
a:link, a:visited {
background-color: white;
color: black;
border: 2px solid green;
padding: 10px 20px;
text-align:
center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active
{
background-color: green;
color: white;
}
उदाहरण
यह उदाहरण विभिन्न प्रकार के कर्सर को प्रदर्शित करता है (लिंक के लिए उपयोगी हो सकता है):
<span style="cursor: auto">auto</span><br>
<span style="cursor:
crosshair">crosshair</span><br>
<span style="cursor:
default">default</span><br>
<span style="cursor: e-resize">e-resize</span><br>
<span style="cursor: help">help</span><br>
<span style="cursor:
move">move</span><br>
<span style="cursor: n-resize">n-resize</span><br>
<span style="cursor: ne-resize">ne-resize</span><br>
<span style="cursor:
nw-resize">nw-resize</span><br>
<span style="cursor:
pointer">pointer</span><br>
<span style="cursor: progress">progress</span><br>
<span style="cursor: s-resize">s-resize</span><br>
<span style="cursor:
se-resize">se-resize</span><br>
<span style="cursor: sw-resize">sw-resize</span><br>
<span style="cursor: text">text</span><br>
<span style="cursor:
w-resize">w-resize</span><br>
<span style="cursor: wait">wait</span>