Solved

css, html

Posted on 2016-10-25
6
48 Views
Last Modified: 2016-11-15
A few questions below:

1. When div is mouseover, i want to change the font color to black. Now is not working.
2. I use  <span style="font-family:'Arial Rounded MT';font-weight:bolder;font-size:23px;">Stanton, CA</span> but it is still not round and bold enough. How can make it more round and bolder?

3. I try to put all style inline. but somehow it is not working. Can you help me?

4. I have div inside of style. I would like to have little control. like StantonDiv and ChinoDiv can have the style only.
It is just because I have other <div> inside of the same page and I do not want them to use the style.


Thanks,



  <style>
        div
        {
            border:2px solid;border-color:darkred;background-color:darkred;
           
        }      
        div:hover
        {
            background-color:yellow;     
            color:black;                         
        }
    </style> 
                    <div style="height:80px;width:300px;text-align:center;" id="StantonDiv">
                          <a style="text-decoration: none;color:white;" href="#"> 
                                <p>                                     
                                    <span style="font-family:'Arial Rounded MT';font-weight:bolder;font-size:23px;">Stanton, CA</span>
                                     <br />
                                    <span style="font-family:'Brush Script MT';font-size:20px;">Orange & Los Angeles Area</span>                                    
                                </p>
                         </a>
                    </div>
                    <div style="height:80px;width:300px;text-align:center;" id="ChinoDiv">
                          <a style="text-decoration: none;color:white;" href="#"> 
                                <p>                                     
                                    <label style="font-family:'Arial Rounded MT';font-weight:bolder;font-size:23px;">Chino, CA</label>
                                     <br />
                                    <label style="font-family:'Brush Script MT';font-size:20px;">Inland Empire Area</label>                                    
                                </p>
                         </a>
                    </div>                   

Open in new window

0
Comment
Question by:ITsolutionWizard
  • 4
  • 2
6 Comments
 
LVL 20

Accepted Solution

by:
Russ Suter earned 500 total points
ID: 41858959
You need to apply the style to the <p> elements inside the div. Add this to your CSS:
        div:hover p {
          color: black;
        }

Open in new window

Or if you want to apply the color to all elements (regardless of type)...
        div:hover * {
          color: black;
        }

Open in new window

0
 

Author Comment

by:ITsolutionWizard
ID: 41858964
it does not work
0
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41859017
It does. Here's proof:
https://jsfiddle.net/1roz2v19/

Although I realize I only answered your first question. Inline styles are generally frowned upon and should not be used in most cases. You should put all your style markup in CSS and use class declarations whenever possible.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ITsolutionWizard
ID: 41859020
I need to use inline css
0
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41859026
Why? There's almost never a good reason. You will create problems for yourself in the 4th question if you do. You cannot control inline styles with CSS. Inline styles ALWAYS override CSS unless your CSS markup uses the !important directive and your inline style does not.

You can accomplish exactly the same result using classes. Give me 5 minutes to work up an example.
0
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41859039
OK, here is the exact same layout using only CSS.
https://jsfiddle.net/1roz2v19/1/

Advantages:
- The page load is faster because browsers can cache CSS and reuse styles rather than declaring the same style repeatedly.
- Your markup is much easier to maintain because you can change a single style and it will automatically update the entire website.
- Styles can be easily applied, overridden, and manipulated.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Centering a nested div 16 55
Angular 2 complaining about map file 7 52
CSS Font Arial Narrow 1 26
Change text to radio button and calendar form 2 32
This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now