Changing hyperlink color without overriding font - html

I'm currently using this ccs:
/* A Free Design by Bryant Smith (bryantsmith.com) */
html, body {
text-align: center;
}
p {text-align: left;}
body {
margin: 0;
padding: 0;
background: #333333 url(images/img01.gif) repeat-x;
text-align: justify;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 13px;
color: #666666;
background-color:#252F33;
}
*
{
margin: 0 auto 0 auto;
text-align:left;}
#header {
position:relative;
width: 680px;
height:99px;
margin-left:29px;
margin-right:21px;
background: url(header.png) no-repeat;
}
#page
{
margin: 0 auto 0 auto;
display: table;
height: 100%;
position: relative;
overflow: hidden;
background: #252F33 url(background.png) repeat-y;
width: 730px;
}
.title
{
position:relative;
left:30px;
top:22px;
text-align:left;
font-family:Georgia, "Times New Roman", Times, serif;
font-size:32px;
font-weight:normal;
color:#252F33;
}
.subText
{
position:relative;
left:62px;
top:26px;
text-align:left;
font-family:Georgia, "Times New Roman", Times, serif;
font-size:12px;
font-weight:bold;
color:#CEEAEE;
}
.articleTitle
{
text-align:left;
padding-left:25px;
padding-top:10px;
padding-bottom:10px;
color: #2C4969;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:24px;
font-weight:bold;
}
.articleContent
{
width:auto;
position:relative;
padding-left:50px;
padding-right:75px;
color:#101214;
text-align:left;
font-family:Arial, Helvetica, sans-serif;
line-height:18px;
}
.rightLinks
{
width: 102px;
font-size:11px;
font-weight:bold;
line-height:21px;
height:auto;
margin-right:-3px;
background-image:url(links_branch.png);
background-repeat:no-repeat;
text-align:right;
float:right;
}
.rightLinks a:hover
{
color:#667765;
}
.rightLinks .linkTitle
{
font-size:13px;
font-weight:bold;
margin-top:27px;
margin-bottom:32px;
margin-right:5px;
}
#bar
{
position:relative;
width: 680px;
height:57px;
margin-left:29px;
margin-right:21px;
background: url(bar.png) no-repeat;
}
.menuLink
{
height:36px;
width: 120px;
text-align:center;
float:left;
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
color:#252F33;
padding-top:19px;
}
.menuLink:hover
{
background: url(bar2.png) repeat-x;
}
a
{
text-decoration:none;
color:#252F33;
}
#pageContent
{
width: 680px;
height:500px;
}
#footer {
width: 730px;
height:60px;
background: url(footer.png) no-repeat;
text-align:center;
font-size:10px;
color:#667765;
padding-top:34px;
}
#footer a
{
font-size:10px;
color:#667765;
}
html, body {
text-align: center;
}
p {text-align: left;}
and I want to change the hyperlink color. I tried the advice here: http://www.ssi-developer.net/css/link-colours.shtml of including this code:
<style type="text/css">
<!--
a:link {color: #000000; text-decoration: underline; }
a:active {color: #0000ff; text-decoration: underline; }
a:visited {color: #008000; text-decoration: underline; }
a:hover {color: #ff0000; text-decoration: none; }
-->
</style>
but including the code changed both the font and the margins. How can I alter the css that I'm using so as to alter the hyperlink color without altering the font or margins?

The best I can offer you is a sort-of answer, as there is nothing in the provided material that would affect your text in the manner described. I can however provide some cleaned up CSS.
/*BASIC STRUCTURE*/
* {
margin: 0 auto;
position:relative;
padding: 0;
}
html, body {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 13px;
text-align:left;
color: #666;
}
body {
margin: 0;
background: #333 url(images/img01.gif) repeat-x;
background-color:#252F33;
}
/*TYPOGRAPHY*/
a {
outline: none;
color: #000;
}
a:active {
color: #0000ff;
}
a:visited {
color: #008000;
}
a:hover {
color: #ff0000;
}
/*SECTIONS*/
#header {
width: 680px;
height:99px;
margin: 0 21px 0 29px;
background: url(header.png) no-repeat;
}
... etc
There are a few things to note about the CSS above, which I'll go through as I assume you are at a beginner-level (excuse me if not!).
First of all, note that I have absorbed your second snippet into the original CSS file, which is where pretty much any and all of your CSS should be. The snippet you provided for styling your links looked like something placed in the <head>section of your HTML. While this does work, it is not ideal for working on your project in the future - keep all the CSS rules in one place, and in the order of specificity required.
Next, note how the text-alignrule is now only mentioned once, as part of the html, body rule. Again, this comes down to specificity but basically once I have declared that everything in my HTML and page body should be text-align: left, then there is no need to repeat that in any other rule unless I wish to change it (text-align: right). This applies to all CSS, it's where the 'Cascading' part comes from. If a rule is there simply to repeat an already defined style (eg. your p rule), then you can get rid of it.
Default stylings need not be mentioned - links default to text-decoration: underline on most browsers, so no real need to specify it unless you are changing it.
The Universal Selector (the * rule) is a powerful beast, and should be handled with care. Basically, any rule you put here will try to apply itself to every element on the screen. Use it to declare default styles or rules only. I have included position: relative as an example. Using it to delcare everything be centered within its parent element (margin: 0 auto;) may be unwise.
You might also look into placing a browser reset at the top of your code. This removes any styling applied to elements by various browsers and gives you 100% control over how your page looks. One of the most popular is the reset by Eric Meyer.
Lastly, see how I have broken up even this small amount of CSS into chunks? This gives your CSS much more structure and hence is much easier to read and code. I commonly use chunks like Basic Structure, Typography, Header, Elements, Footer, and use #import for my reset. I also use CSS shorthand where possible, also aiding readability.
As for your exact problem, clean up your CSS file, put all your CSS in one place, remove duplicated rules, understand and decide exactly what each text- or font- or margin rule is supposed to be doing, and you will probably arrive at the solution.
And read up on specificity.

Related

Fix div to center of page, but don't overflow when resizing

I'm trying to make a navbar that fits the length of another div where I'm listing some data. I want it to be fixed to the top of the page no matter where you scroll. I have it like that, but when you resize the window from the right side and make it smaller, it'll eventually go off the page. I'm pretty sure it has something to do with the fact that I'm translating it over 50% and it's not caring if it's going off screen, so is there some sort of way to easily counteract that? I'd like it to behave the way the table does. When it's about to go off screen, stop moving it over. Thanks for any help
Here is a demonstration:
http://box.endurehosting.com/contents/public/Screen-recorder-fri-jan-03-2020-21-31-14.webm
Here's the live website:
https://dev.theromdepot.com/archive.php?home
Here is my HTML:
<div id="nav-bar">
<input id="search" placeholder="Search" type="input"></input>
</br>
</br>
<div id="title-bar">
<p>Name</p>
<p>Count</p>
</div>
</div>
Here is my CSS (I'm using SCSS)
$mainBackground: #1d1f21;
$textHoverColor: #919191;
#font-face {
font-family: 'Muli';
src: url('../fonts/muli.ttf') format('truetype');
}
body {
background-color:$mainBackground;
}
a {
color:white;
text-decoration: none;
transition: color .2s;
&:hover {
color:$textHoverColor;
transition: color .2s;
}
}
#nav-bar {
position:fixed;
width:25%;
min-width:800px;
left: 50%;
transform: translateX(-50%);
background-color:grey;
padding:10px;
z-index:1;
#search {
&::placeholder {
opacity:1;
}
position:relative;
border:none;
border-radius:2px;
padding:5px;
font-size: 20px;
line-height: 10px;
&:focus {
box-shadow:2px 2px 5px darkgrey;
}
}
#title-bar{
position:relative;
color: white;
p {
display:inline-block;
font-size: 16px;
font-weight: 600;
letter-spacing: 2px;
padding-bottom: 5px;
}
}
}
#list {
margin:auto;
width:25%;
min-width:800px;
color:white;
#results {
position:relative;
top:100px;
width:100%;
.row {
font-family: Muli;
font-size: 14px;
word-spacing: 2px;
position:relative;
width:100%;
height:18px;
padding-top:5px;
p {
display:inline-block;
position:absolute;
&:nth-child(1) {
// left:5%;
}
&:nth-child(2) {
left:51%;
}
&:nth-child(3) {
left:67%;
}
&:nth-child(4) {
margin:0;
left:82.5%;
}
}
}
}
}
The problem is your min-width property, which won't let it shrink under 800px. So when you are sizing the window down and passing 800px, the navbar stays the same width.
One solution could be using media queries in order when you reach the screen-width of 800pxs, you give the css property another value.
If that min-width attribute is not needed, since you are setting the width, you can just remove it and it will work.

Font displayed twice on Ipad2 and iphone4 - working fine on other desktop browsers

I use fontsquirrel's & google's fonts and they work perfectly fine on desktop browsers (IE, safari,chrome, firefox).
But when it comes to mobile safari, specially ipad2 and iphone4, the font appears twice, meaning, it shows 2 times the same word as if it was twice the same text ! The problem is on the H1.
I tried using sans serif font and it's the same...
I tried to change the font-weight, font-size etc but it doesn't change anything.
body {
color:#FFF;
font-family: 'Raleway', sans-serif;
font-weight: normal;
/*font-family: 'Open Sans', sans-serif;*/
min-width:960px;
top:0;
left:0;
position:absolute;
height:100%;
width:100%;
margin:0;
background-size:cover;
}
.ie body {
filter: dropshadow(color=#000000, offx=0, offy=1); }
h1 {
font-size:88px;
text-align:center;
padding-top:30px;
font-weight:700;
font-family:'quicksandregular',arial, sans-serif;
}
#media screen and (max-width:768px){ /* tablettes */
body {
min-width: initial !important;
font-weight: normal; /* */
font-size: 68px; /* */
}
.wrapper{
width:100%;
}
.styled div {
margin-bottom:10px;
}}
#media screen and(max-width:420px){ /* tel */
body{
font-weight: normal; /* */
font-size: 68px; /* */
}
h1{
float:initial;
text-align: center;
margin-left:0px;
margin-bottom:0px;
}
#header {
width: 100%;
}
.styled div {
margin-bottom:10px;
font-size: 40px;
font-weight: normal;
text-align: center;
width:80px;
border-radius:80px;
height:80px;
}
#Content h2 {
margin: 0px 0px 0px 0px;
padding: 0px;
text-align: center;
font-size: 29px;
font-weight: 300;
}
Many thanks for your help !!
Laƫtitia
The browser is applying a bold font weight, which is causing the problem because there is no bold quicksand. All you have to do is set font-weight:normal; for text elements that are appearing twice.
Your problem is talked about at length here:
http://www.fontsquirrel.com/forum/discussion/277/webfonts-showing-up-twice/p1

Positioning three divs left, center and right

This community has already been a big help. I have one noob question. I did do a search, but didn't turn up this situation, so apologies if this has been asked before.
I have a "nav" div currently sitting in a wrapper div. Nested in my nav div are three child elements that I want to position left, center, and right accordingly. I tried floating the three elements but they're all stacking on one side. I would like the logo div on the left, header in the center, and phone number on the right.
I know these can be positioned more precisely with absolute positioning, but since I'm trying to keep the layout as fluid as possible, is there another way?
Here is my HTML
<div class="wrapper">
<div class="nav">
<div class="logo"><em>BLI </em></div>
<div class="header"><em>California's Leader in Workers' Compensation</em></div>
<div class="phonenumber">Call us:<br>
909-256-0525</div>
</div>
And my CSS:
.wrapper{
min-width:1200px;
position:relative;
width:100%;
overflow:auto;}
.nav{
color:#FFFFFF;
font-size:1.563em;
font-weight:bold;
float:left;
font-family: Arial;
background-color:#C7C2C2;
width:100%;
height:80px;
display:inline;
}
.logo{
font-family: Georgia, "Lucida Bright", "DejaVu Serif", Georgia, serif;
font-weight: bold;
font-size: 2em;
width: 50px;
color: #0E2B5E;
top: 9px;
clear: both;
float: left;
}
.header{
text-shadow:black 0.1em 0.1em 0.2em;
padding-top:40px;
clear:both;
width:300px;
text-align:center;
float:left;
}
.phonenumber{
text-shadow: black 0.1em 0.1em 0.2em;
float: left;
font-size: 1em;
padding: 5px;
}
Any general responsive design tips would also be appreciated.
Thanks!
You can use display:table; on the wrapper and display:table-cell; on all its child elements.
This treats the wrapper div as if it were a table element with the width of 100%, and all its child elements as table cells. (http://www.w3schools.com/cssref/pr_class_display.asp)
.wrapper{
width: 100%;
height:auto;
display:table;
background-color:gray;
}
.logo{
display:table-cell;
text-align:left;
width:33%;
}
.header{
display:table-cell;
text-align:center;
width:33%;
}
.phonenumber{
display:table-cell;
text-align:right;
width:33%;
}
By making the wrapper 100% and its children 33%, its now responsive too!
I cleared out your current styling to make it easier for you to read.
Fiddle: http://jsfiddle.net/mLmcfrup/
Here i can solved your problem and it is fully Responsive css code and it is working in all browser's and change width according to browser size.It can be used in mobile, pc and other resolution. I hope it helps you.
Live Working Demo
HTML Code:
<div class="main">
<div class="left">left</div>
<div class="middle">middle</div>
<div class="right">right</div>
</div>
CSS Code:
.main
{
width:100%;
position:relative;
}
.left
{
width:20%;
float:left;
position:relative;
background-color:red;
}
.middle
{
width:60%;
float:left;
position:relative;
background-color:green;
}
.right
{
width:20%;
float:left;
position:relative;
background-color:blue;
}
Result:
To place the inner divs side-by-side, and keeping it fluid, use the css display properties table and table-cell.
.nav {
display: table;
width: 100%;
}
.nav > div {
display: table-cell;
}
Remove all the floats and stuff, and let the nav work like a table, placing it's children side by side like inline cells...
Here's a simple example of how it works (without all of your styling): http://jsfiddle.net/1co0qLx9/
Here are 2 best solutions of your concern.
I have created 2 fluid layouts based on your code.
First with "float" so that you could easily relate and implement quickly.
URL:- http://sandeepparashar.com/stackoverflow/fluid-layout-with-float.html
Second with "box-flex". Becasue float has been out dated and you would get a chance to know about new CSS3 properties. Also box flex has no width restriction.
URL:- http://sandeepparashar.com/stackoverflow/fluid-layout-with-box-flex.html
CSS Code with Float layout:
.wrapper {}
.nav {
width:100%;
vertical-align:middle;
box-sizing:border-box;
color: #FFFFFF;
font-size: 1.563em;
font-weight: bold;
font-family: Arial;
background-color: #C7C2C2;
height: 80px;
}
.logo {
font-family: Georgia, "Lucida Bright", "DejaVu Serif", Georgia, serif;
font-weight: bold;
font-size: 2em;
color: #0E2B5E;
float:left;
width:100px;
padding-top:10px;
}
.header {
text-shadow: black 0.1em 0.1em 0.2em;
text-align: center;
margin:0 200px 0 100px;
padding-top:25px;
}
.phonenumber {
text-shadow: black 0.1em 0.1em 0.2em;
font-size: 1em;
padding: 5px;
float:right;
width:200px;
padding-top:10px;
}
HTML DIV position changes with Float layout:
<div class="wrapper">
<div class="nav">
<div class="phonenumber">Call us:<br>
909-256-0525</div>
<div class="logo"><em>BLI </em></div>
<div class="header"><em>California's Leader in Workers' Compensation</em></div>
</div>
</div>
CSS3 Code with Box Flex layout:
.wrapper {}
.nav {
display:box;
display:-webkit-box;
display:-ms-flexbox;
display:-moz-box;
box-orient:horizontal;
-webkit-box-orient:horizontal;
-ms-box-orient:horizontal;
-moz-box-orient:horizontal;
-webkit-box-align:center;
-ms-flex-align:center;
-moz-box-align:center;
width:100%;
vertical-align:middle;
box-sizing:border-box;
color: #FFFFFF;
font-size: 1.563em;
font-weight: bold;
font-family: Arial;
background-color: #C7C2C2;
height: 80px;
}
.logo {
font-family: Georgia, "Lucida Bright", "DejaVu Serif", Georgia, serif;
font-weight: bold;
font-size: 2em;
color: #0E2B5E;
}
.header {
box-flex:1;
-webkit-box-flex:1;
-ms-flex:1;
-moz-box-flex:1;
display:block;
text-shadow: black 0.1em 0.1em 0.2em;
text-align: center;
}
.phonenumber {
text-shadow: black 0.1em 0.1em 0.2em;
font-size: 1em;
padding: 5px;
}
If required more help, Please most welcome :)

Getting rid of the space in heading (HTML, CSS related)

Just wondering how to get rid of the unnecessary looking spaces
in my heading. I want my header to look similar to the capture 2 (2nd picture) but there are unnecessary spaces that I can't seem to get rid of. I ran it through jsfiddle:
http://jsfiddle.net/yT6h6/ and I can still see the spaces even though I don't think there was anything wrong with the code. Please take a look at this and greatly appreciated if you can help me.
HTML Code:
<div class="content">
<div class="heading"><b style="font-size:14px; font-family:'Arial', Gadget, sans-serif"><b style="font-size:9px;">Home \\ Current Students \\</b>
</b>
<br />FBE Degrees & Electives
<br>
<span class="style11">FBE Degrees & Other Courses for FBE students including Elective courses</span>
</div>
CSS Code:
.heading {
height: auto;
width: 525px;
background-color: #333333;
font-family:"Courier New", Courier, monospace;
font-size: 28px;
color: #DBDBDB;
padding-left: 30px;
font-weight: bold;
padding-top: 5px;
margin-top: 5px;
padding-bottom: 5px;
padding-right: 20px;
background-repeat: no-repeat;
background-position: left center;
}
.content {
height: auto;
float: left;
width: 575px;
background-repeat: repeat;
background-color: #FFFFFF;
}
.style11 {
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
line-height: 15px;
color: #336666;
}
a.link5:link {
color: #FFFFFF;
}
a.link5:visited {
color: #FFFFFF;
}
a.link5:hover {
color: #E9E8C7;
}
a.link5:active {
color: #E9E8C7;
}
try this one remove line-height and add display:block
.style11 {
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
display:block;
color: #336666;
}
I think you firstly need to seriously tidy up that HTML and use some more natural elements. The heading should be a H of some level, probably h1. The paragraph tags make more sense for the text. Everything will be far cleaner and easier to solve if you do this. Here's my suggestion that changes the HTML and fixes your margin issues.
HTML
<div class="content">
<div class="heading">
<p class="crumbs">Home \\ Current Students \\</p>
<h1>FBE Degrees & Electives</h1>
<p class="subheading">FBE Degrees & Other Courses for FBE students including Elective courses</p>
</div>
</div>
CSS
p {
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
color: #336666;
}
a {
color:#fff;
text-decoration:none;
}
.heading {
background:#333333;
padding:20px;
}
.heading p {
margin:0;
padding:0;
line-height:10px;
}
h1 {
margin:0;
margin-bottom:5px;
font-family:"Courier New", Courier, monospace;
font-size:28px;
line-height:36px;
color:#DBDBDB;
}
Fiddle here:
http://jsfiddle.net/yT6h6/6/
It can be simplified more actually (I left some of your classes in there even though they aren't used), but this is at least a lot neater to work with.
Hey i've tried your code see at: http://jsbin.com/awonek/1/edit
Looks fine to me.
could code try
div#heading{
margin-bottom:-20px;
}
what browsers have you tried it in?
Added some changes: See http://jsbin.com/uvurev/1/edit
<div class="content">
<div class="heading">
Home \\ Current Students \\
<h2 class="M_logo_text">FBE Degrees & Electives</h2>
<span class="style11">FBE Degrees & Other Courses for FBE students including Elective courses</span>
</div>
</div>
CSS
div.heading {
height: auto;
width: 525px;
background-color: #333333;
font-family:"Courier New", Courier, monospace;
color: #DBDBDB;
padding-left: 30px;
font-weight: bold;
padding-top: 5px;
margin-top: 5px;
padding-bottom: 5px;
padding-right: 20px;
background-repeat: no-repeat;
background-position: left center;
}
.content {
height: auto;
float: left;
width: 575px;
background-repeat: repeat;
background-color: #FFFFFF;
}
.style11 {
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
line-height: 15px;
color: #336666;
}
a.link5{
font-size:9px; font-family:'Arial', Gadget, sans-serif
margin-right: -2px;
text-decoration: none;
}
a.link5:link {
color: #FFFFFF;
}
a.link5:visited {
color: #FFFFFF;
}
a.link5:hover {
color: #E9E8C7;
}
a.link5:active {
color: #E9E8C7;
}
/*
added style
*/
b.type1{
font-size:9px; font-family:'Arial', Gadget, sans-serif
}
h2.M_logo_text{
font-size: 20px;
margin:0px;
}

Link not working inside of <li>

I looked at the answers to similar questions, but none provided the help I need; I'm still getting unresponsive links !?
To be clearer, by unresponsive links I mean the link does not work; they style exactly as expected.
Here's the CSS:
#nav3 { padding: 0; margin:15px 15px 0; height:29px; background-repeat: repeat; background-position: left top; }
.ddcolortabs { padding: 0; width: 100%; }
.ddcolortabs ul { font: normal 13px Arial, Verdana, sans-serif; margin:0 0 0; padding:0; list-style:none; }
.ddcolortabs li { display:inline; margin:0 2px 0 0; padding:0; }
.ddcolortabs a { float:left; color: #4963AE; background: #B9D6E5 url(../../content/themes/wd/images/tabs/color_tabs_left.png) no-repeat left top; margin:0 6px 0 0; padding:0 0 1px 3px; text-decoration:none; letter-spacing: 1px; font-weight: bold; }
.ddcolortabs a.selected { background: #98a5d3 url(../../content/themes/wd/images/tabs/color_tabs_left.png) no-repeat left top; color: #FFF; }
.ddcolortabs a span { float:left; display:block; padding: 8px 20px 6px 19px; background: transparent url(../../content/themes/wd/images/tabs/color_tabs_right.png) no-repeat right top; }
And here's the html:
<div id="nav3">
<div id="colortab2" class="ddcolortabs">
<ul style="margin-left:10px;">
<li><span>Most Active</span> </li>
<li><span>Most Popular</span></li>
<li><span>Most Recent</span></li>
<li><span>Browse Categories</span></li>
</ul>
</div>
</div>
My bad, higher in the markup I had a div styled with z-index: -1
I just ran into this issue. I solved it by including the full link for the page plus the anchor.
Click here
Annoying issue to have. It was working fine locally prior to making this change. I am not sure if the web host's server plays a part in this somehow?