I know this sounds like an obvious question and answer, but I have spent a long time trying to figure this out, and for some reason, none of the answers are not working for me. Honestly, this is probably going to be a simple obvious answer I just can't catch. But here's the problem: I am making a website out of HTML5, CSS, and some PHP.
The issue is, that my links appear blue and purple with an underline. I know this is how they are supposed to look, but I have tried many different ways to re-style the links with text-decoration: none, and different colors and so on.
Here is my CSS and the HTML part with a link:
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a {
text-decoration: none;
color: brown;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants.">
</div></a>
I'm not sure if you needed all that, but there it is anyway.
For hover color change you can use this css
.sidebar a:hover{color:red; }
For keep the color focus after click
.sidebar a:focus{color:blue; }
1) You need to change your code from </div></a> at the end to this: </div></a></div>
2)Links can be styled differently depending on what state they are in.:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
You can read more about this in: https://www.w3schools.com/css/css_link.asp
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a, a:link, a:visited{
text-decoration: none;
color: brown;
}
a:hover, a:active{
color: green;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants."/>
</div>
</a>
</div>
a {
text-decoration: none;
color: brown;
}
is where you need to make changes to edit links
to change hover options:
a:hover {
style it here
}
and for already visited links on your site:
a:visited {
style it here
}
You asked how to style links.
a{
color: red;
cursor: wait;
font-size: 24px;
transition: color 0.3s, text-shadow 0.3s;
text-decoration: none;
}
a:hover{
color: green;
text-shadow: 1px 2px 3px #000;
text-decoration: overline;
}
a:active{
font-weight: 900;
}
Working link.
Related
This is basically my header and its a small project but my first time using OOCSS. I know that the principles are to seperate structure and skin to prevent repetetive code. But since my project is so small I have no clue of how i could implement it?
body {
font-family: "Lato", sans-serif;
background-color: white;
}
.wrapper {
max-width: 1024px;
margin: 0 auto;
background-color: #eee;
border: 1px solid black;
}
.header {
height: 350px;
background-image: url(bilder/vietnam_770.jpg);
background-repeat: no-repeat;
background-position: center;
}
.header h1 {
font-family: "Roboto", sans-serif;
font-size: 30px;
font-weight: 700;
float: left;
margin-left: 150px;
margin-top: 10px;
}
.meny ul {
list-style-type: none;
display: flex;
flex-direction: row;
float: right;
margin-right: 170px;
margin-top: 17px;
}
.meny li {
margin-left: 1em;
}
.meny a {
text-decoration: none;
font-size: 14px;
font-weight: 700;
color: black;
padding: 0.25em;
}
.meny a:hover {
color: darkgrey;
}
.meny .current {
border-bottom: 1px solid black;
}
.meny .current:hover {
color: black;
}
.beskrivning {
float: right;
width: 250px;
margin-right: 175px;
margin-top: 80px;
text-align: center;
}
.beskrivning h2 {
font-family: "Lato", sans-serif;
font-size: 24px;
font-weight: 700;
}
.beskrivning p {
margin-top: 0.5em;
font-size: 14px;
font-weight: 700;
line-height: 15px;
}
Tried reading and looking for examples but all examples had repetetive code which made it easy to determine.
I would like to know how to align the image next to the text in my code.
Please disregard how messy it is. I was doing a project for school and I didn't know how to fix this issue I'm having.
The project isn't mandatory although it's for a competition to win a raspberry pi that I need for a future project involving bitcoins.
https://jsfiddle.net/kdn1x2hk/3/
<!DOCTYPE! html>
<html>
<head>
<style>
body,
html {
margin-top: -11px;
margin: 0;
height: 100%;
min-width: 1000px;
background-color: red;
}
.bg {
margin-left: 20%;
width: 60%;
background-color: grey;
border-left: thick solid black;
border-right: thick solid black;
}
.background {
background-image: url("images/background.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
min-height: 100%;
}
.banner {
width: 100%;
border-bottom: thick solid black;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
border-bottom: thick solid black;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none!important;
font-family: "Arial Black", Gadget, sans-serif;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #FFD700;
color: black;
}
.header {
font-size: 80pt;
font-family: "Arial Black", Gadget, sans-serif;
color: black;
text-align: center;
min-width: 80pt;
}
.dotted_line {
border-top: 2px dashed black;
width: 70%;
}
.paragraph {
font-size: 15pt;
width: 500px;
margin-left: 0%;
color: black;
}
.sub_header {
text-align: center;
font-size: 50pt;
color: black;
}
.credit {
width: 560;
size: 20pt;
text-align: center;
font-style: italic;
}
.video {
width: 70%;
margin-left: 15%;
border: thick solid black;
}
.credit_link {
text-decoration: none;
}
#image {
width: 45%;
}
#text {
width: 45%;
float: left;
font-size: 15pt;
color: black;
padding-top: 20px;
-webkit-text-size-adjust: none;
-ms-text-size-adjust: none;
-moz-text-size-adjust: none;
text-size-adjust: none;
}
.format {
width: 90%;
margin-left: 10%;
}
</style>
</head>
<body>
</body>
</html>
Changes:
Moved the #text before the #image inside format class container and used display:flex instead of float:left on your #text container to also provide vertical alignment.
Added align-items:center on format class to vertically align both of its contents i.e text and image.
Updated fiddle : https://jsfiddle.net/sbakj4x0/
body,
html {
margin-top: -11px;
margin: 0;
height: 100%;
min-width: 1000px;
background-color: red;
}
.bg {
margin-left: 20%;
width: 60%;
background-color: grey;
border-left: thick solid black;
border-right: thick solid black;
}
.background {
background-image: url("images/background.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
min-height: 100%;
}
.banner {
width: 100%;
border-bottom: thick solid black;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
border-bottom: thick solid black;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none!important;
font-family: "Arial Black", Gadget, sans-serif;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #FFD700;
color: black;
}
.header {
font-size: 80pt;
font-family: "Arial Black", Gadget, sans-serif;
color: black;
text-align: center;
min-width: 80pt;
}
.dotted_line {
border-top: 2px dashed black;
width: 70%;
}
.paragraph {
font-size: 15pt;
width: 500px;
margin-left: 0%;
color: black;
}
.sub_header {
text-align: center;
font-size: 50pt;
color: black;
}
.credit {
width: 560;
size: 20pt;
text-align: center;
font-style: italic;
}
.video {
width: 70%;
margin-left: 15%;
border: thick solid black;
}
.credit_link {
text-decoration: none;
}
#image {
width: 45%;
}
#text {
width: 45%;
font-size: 15pt;
color: black;
padding-top: 20px;
-webkit-text-size-adjust: none;
-ms-text-size-adjust: none;
-moz-text-size-adjust: none;
text-size-adjust: none;
}
.format {
width: 90%;
margin-left: 10%;
overflow: hidden;
align-items: center;
display: flex;
align-items: center;
}
<!DOCTYPE html>
<body>
<div class="background">
<div class="bg">
<img src="https://i.imgur.com/gsceMM5.png" class="banner">
<ul>
<li><a class="active" href="index.html">Home</a></li>
<li>Stats</li>
<li>History</li>
<li>Info</li>
<li>Contact</li>
</ul>
<p class="header"> WELCOME</p>
<hr class="dotted_line" />
<p class="sub_header">What is Bitcoin?</p>
<video class="video" poster="images/thumbnail.jpg" controls>
<source src="videos/info.mp4" type="video/mp4">
</video>
<p class="credit">
(Credit to <a class="credit_link" href="https://www.youtube.com/user/weusecoins">WeUseCoins</a> on youtube.com)
</p>
<div class="format">
<p id="text">
Bitcoin is a new currency that was created in 2009 by an unknown person using the alias Satoshi Nakamoto. Transactions are made with no middle men – meaning, no banks! Bitcoin can be used to book hotels on Expedia, shop for furniture on Overstock and
buy Xbox games. But much of the hype is about getting rich by trading it. The price of bitcoin skyrocketed into the thousands in 2017.
</p>
<img src="https://i.imgur.com/BGsKZms.png" id="image" />
</div>
</div>
</div>
</body>
I am having a tiny little problem with the CSS below.
While the boxes all line up, I'm trying to get the text to appear inside the boxes, and then to stylize the text...everything I've tried seems to fail. Something is overriding it or the browser is just ignoring it.
Further still is that the text "Foundation 100 - Presence" always outstrips its intended area. This text is dynamic and will change constantly. So the size of this block will change based on the number of characters in the block. So this value in the CSS -> width:489px; will change accordingly.
Furthermore, each one of those blocks has contain an HTML Form link.
...
A few restrictions no javascript, no java, and no php. straight HTML and CSS.
Anyone want to take a crack at this one ????
The Code on the page:
#video_line {
width: 489px;
text-align: center;
}
#vl_desc {
float: left;
width: 200px;
height: 30px;
background: #ffffff;
}
#vl_rental {
float: left;
width: 62px;
height: 20px;
background: #ff0000;
}
#vl_sales {
display: inline-block;
margin: 0 auto;
width: 62px;
height: 20px;
background: #00ff00;
}
#vl_view {
float: right;
width: 62px;
height: 20px;
background: #0000ff;
}
#vl_text_desc {
text-align: right;
font-size: 19 px;
font-weight: 300;
}
<div id="video_line">
<div id="vl_desc">
<p id="vl_text_desc">Foundation 100 - Presence</p>
</div>
<div id="vl_rental">TEXT</div>
<div id="vl_sales">TEXT</div>
<div id="vl_view">TEXT</div>
</div>
This is what I am looking for ->
Here is a start
#video_line {
width:489px;
text-align:center;
}
#vl_desc {
float:left;
width:250px;
height: 30px;
background: #ffffff;
font-size: 18px;
font-family: arial;
font-weight: bold;
padding: 3px 6px;
}
#vl_rental {
float:left;
width:62px;
height: 20px;
background: #ff0000;
color: white;
font-size: 18px;
font-family: arial;
font-weight: bold;
padding: 3px 6px;
}
#vl_sales {
float:left;
width:62px;
height: 20px;
background: #00ff00;
color: darkgreen;
font-size: 18px;
font-family: arial;
font-weight: bold;
padding: 3px 6px;
}
#vl_view {
float:left;
width:62px;
height: 20px;
background: #0000ff;
color: yellow;
font-size: 18px;
font-family: arial;
font-weight: bold;
padding: 3px 6px;
}
#vl_text_desc {
text-align: right;
font-size: 19 px;
font-weight: 300;
}
<div id="video_line">
<div id="vl_desc"><span id="vl_text_desc">Foundation 100 - Presence</span></div>
<form id="vl_rental">TEXT</form>
<form id="vl_sales">TEXT</form>
<form id="vl_view">TEXT</form>
</div>
Simply change following styles:
#vl_text_desc {
margin-top: 0;
}
#video_line {
width: 489px;
text-align: center;
display: inline;
}
#vl_view {
float: left;
}
#vl_desc {
float: left;
width: 200px;
height: 30px;
background: #ffffff;
margin-right: 16px;
margin-top: 0;
}
From here you can modify font-family and color as you prefer.
My body on my site is smaller on all edges for some reason, i have no idea why, here is my site to preview what the spaces / edges are doing: csgodice.co.uk, here is my css code, if you need my html i will edit it and add the html but i think its the css:
CSS:
#font-face{
font-family: "coolvetica"; /* You can name the font whatever you like here */
src: url('fonts/coolvetica rg.ttf') format('truetype'); /* Font directory and format */
}
#header {
margin-right: 50px;
height: 6%;
width: 100%;
border-radius: 3px;
background-color: #FA5858;
}
#logo {
height: 60px;
width: 250px;
}
#steamLogon {
float: right;
margin-top: 0px;
}
#navbar {
float: right;
margin-top: 13px;
margin-right: 100px;
}
#navbar a {
margin-left: 50px;
height: 20px;
width: 70px;
display: align-block;
font-weight: 200;
font-size: 22px;
text-align: center;
text-decoration: none;
color: white;
font-family: coolvetica;
}
#navbar .dropdown {
margin-left: 50px;
height: 20px;
width: 70px;
display: align-block;
font-weight: 200;
font-size: 22px;
text-align: center;
text-decoration: none;
color: white;
font-family: coolvetica;
}
.logout {
font-family: coolvetica;
background-color: #e6e6e6;
font-weight: 300;
height: 25px;
width: 160px;
border: 2px solid #f2f2f2;
}
.logout:hover {
font-family: coolvetica;
font-weight: 300;
font-size: 14px;
color: #262626;
height: 25px;
width: 160px;
background-color: #FA5858;
border: 2px solid #f2f2f2;
}
.account {
font-family: coolvetica;
font-size: 14px;
color: #262626;
height: 20px;
margin: auto;
width: 153px;
background-color: #e6e6e6;
border: 2px solid #f2f2f2;
}
.account:hover {
font-family: coolvetica;
font-size: 14px;
color: #262626;
height: 20px;
width: 153px;
background-color: #FA5858;
border: 2px solid #f2f2f2;
}
/* Dropdown Button */
.dropdown-content {
display: none;
border-radius: 3px;
position: absolute;
height: 45px;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown-toggle:hover .dropdown-content {
display: block;
}
#diceholder {
height: 50%;
width: 85%;
margin: auto;
margin-top: 100px;
background-color: #404040;
}
/* Account.php */
.trade-url {
display: align-block;
font-family: coolvetica;
font-size: 24px;
color: #1a1a1a;
margin-top: 50px;
text-align: center;
margin-left: auto;
margin-right: auto;
}
I assume you mean that the body has a margin and you'd like to remove it - if so, try adding this CSS:
body {
margin: 0;
}
I'm trying to get my background image to show at the top center of the page. The image works fine if I do:
<style>
body {
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed;
}
</style>
I can't seem to work out where I've gone wrong. There must be something I've managed to mess up, I just can't see it. Here is the CSS:
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('img/top_logo_blank_small.png') no-repeat fixed;
color: #fff;
margin: 0;
padding: 0;
}
a {
color: black;
text-decoration: none;
}
/* Typography */
.header h1 {
position: absolute;
width:100%;
top: 50%;
margin-top: -20px;
text-align: center;
letter-spacing: 4px;
}
.header h1 em {
font-size: 1.200em;
font-style: normal;
}
h1 {
font-size: 2.2em;
color: #fff;
}
.content h2 {
font-size: 1.75em;
color: #fff;
letter-spacing: 4px;
text-align: center;
}
.content h2 em {
font-size: 1.2em;
font-style: normal;
}
.content h3 {
text-align: center;
font-size: 1.0em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
margin-bottom: 25px;
}
.content h4 {
margin-top: 0;
text-align: center;
font-size: 0.8em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
}
#banner p {
text-align: center;
}
/* Navigation */
#nav {
margin: 4px 4px 40px;
}
#nav ul {
padding: 0;
margin: auto;
list-style: none;
}
#nav ul li {
width: 50%;
color: #BBB;
float: left;
font-family: 'Cabin Sketch';
font-size: 1.75em;
text-align: center;
background: url(img/scribble_dark.png);
}
#nav ul li a {
display: block;
/*padding: 5px 20px;*/
}
#nav ul li a:hover {
background: #e0d0e0;
}
/* Content */
.container{
max-width: 720px;
margin: 50px auto 0;
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed 0 0;
}
.header {
position: relative;
background-color: #b88fb8;
border-top: 5px solid #ede0ed;
height: 75px;
}
.content {
background-color: #000;
padding: 15px;
margin-bottom: 10px;
}
div#about {
padding:25px;
min-height: 255px;
}
img#portrait {
float: left;
margin-right: 25px;
width: 256px;
height: 256px;
}
div#footer {
width: 100%;
max-width: 720px;
margin: auto;
color: black;
text-align: right;
padding: 0 10px;
font-size: 0.850em;
}
#media screen and (max-width: 650px) {
.container {
width: 90%;
max-width: none;
}
div#footer {
width: 90%;
}
}
Try to change your path for example:
background: #EEE url('../img/top_logo_blank_small.png') no-repeat fixed top;
Because you are in a subfolder, you have to go up of a level I think
Most likely your css file is in a different folder and therefore needs another path to the image file.
The common way is to put css in a separate css/* folder, so the path should be:
url('../img/top_logo_blank_small.png')
This CSS seems to work fine, are you certain that the image exists?
http://jsfiddle.net/ghsNR/
I've just tried it here and it works fine with an image from http://placehold.it/
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('http://placehold.it/500x500') no-repeat fixed top;
color: white;
margin: 0px;
padding: 0px;
}
The most likely cause after observing this is that your CSS isn't actually locating your image correctly. I suggest using tools like the Chrome dev tools, or Firebug to inspect the absolute path that the browser is trying to use to load the image and moving forward from there.
Is the css in the same folder as the page? If you have a different folders, you need to change the URL accordingly.
Maybe change the URL to
'../img/top_logo_blank_small.png'