How to create the expected button in HTML? - html

The first image was captured in Python online course. The second image was captured in my own website. I want to mimic this website for practicing html/css skill. What I want to know is how to create the expected button. Thank you for your reply.
/*Here is my CSS code, which is unfinished.*/
.Matter a:hover{
background-color: rgb(230,230,230);
}
<!-- Here is my HTML code -->
<div class='Matter'>
<h1>Welcome to the Capstone</h1>
<p><a href='#'><b>Video:</b> Introduction: Welcome to the Class</a></p>
<p><a href='#'><b>Reading:</b> Capstone Overview</a></p>
<p><a href='#'><b>Reading:</b> Help Us Learn More About You!</a></p>
</div>

Let's handle your problem step by step:
Styling the link: We are going to add some padding, text decoration and color. We are also using display inline-block for our link take full width.
.Matter a {
padding: 8px;
display: inline-block;
width: 100%;
text-decoration: none;
color: black;
}
Adding hover style:
.Matter a:hover{
background-color: rgb(230,230,230);
}
Adding checkmark: We need to use CSS Pseudo element ::before to add the check mark in front of the link. To add the green circle around the check mark we are using some margin, padding, border radius, background, color and font size. We are also using position to adjust the check mark circle position.
.Matter a::before {
content: '🗸';
margin-right: 8px;
padding: 2px 4px;
background: green;
border-radius: 50%;
color: white;
font-size: 12px;
position: relative;
top: -2px;
}
Here's the complete solution. You can play with it as you wish.
.Matter a {
padding: 8px;
display: inline-block;
width: 100%;
text-decoration: none;
color: black;
}
.Matter a:hover{
background-color: rgb(230,230,230);
}
.Matter a::before {
content: '🗸';
margin-right: 8px;
padding: 2px 4px;
background: green;
border-radius: 50%;
color: white;
font-size: 12px;
position: relative;
top: -2px;
}
<div class='Matter'>
<h1>Welcome to the Capstone</h1>
<p><a href='#'><b>Video:</b> Introduction: Welcome to the Class</a></p>
<p><a href='#'><b>Reading:</b> Capstone Overview</a></p>
<p><a href='#'><b>Reading:</b> Help Us Learn More About You!</a></p>
</div>

Related

Revealing hidden objects upon click of a button not working

I'm trying to set up an aspect of my website where previous articles will be hidden unless someone clicks a button at the bottom of the webpage. I have the div I want hidden until clicked through the display:none functionality. I want the new div to appear and expand the bottom of the page once the button is clicked. To do this, I set the .button:active to change the display to display:block once clicked. Unfortunately, when the button is clicked, nothing happens. I was wondering if you guys could help me with this. I'll include a JS Fiddle of the problem. Thanks!
.StoriesBox {
width: 35.5%;
margin-left: 32.2%;
margin-top: 3%;
line-height: 190%;
}
.StoriesBox2 {
display: none;
width: 35.5%;
margin-left: 32.2%;
margin-top: 3%;
line-height: 190%;
}
.StoriesTitle {
font-size: 165%;
}
.Chinese {
font-family: "Yu Gothic";
font-weight: normal;
}
.StoriesDate {
font-size: 58%;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
margin-top: 4%;
margin-left: 22.5%;
margin-bottom: 5%;
padding: 4%;
padding-top: 1%;
padding-bottom: 3%;
padding-right: 20%;
padding-left: 20%;
text-align: center;
text-decoration: none;
font-size: 70%;
font-family: "eraslight";
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button5 {
background-color: white;
color: black;
border: 2px solid #555555;
}
.button5:hover {
background-color: #555555;
color: white;
}
.button:active .StoriesBox2 {
display: block;
}
<section class="stories">
<div class="StoriesBox">
<div class="StoriesTitle">
<h2>Title Length</h2>
<div class="StoriesDate">
<h3>2018<span class="Chinese"> 年</span> 09<span class="Chinese">月</span> 28<span class="Chinese">日</span></h3>
</div>
<p>Please know, the opinions expressed on this site will portray the cultural, societal, and political differences between China and the United States from my own, personal perspective. This means always highlighting the positives and never sugarcoating
the negatives - a process which always results in concrete critical analysis. If you have any questions, concerns, or just want to chat, please feel free to contact me through one of the media platforms directly below. Thank you and enjoy!</p>
</div>
</div>
<div class="StoriesBox2">
<div class="StoriesTitle">
<h2>Title Length</h2>
<div class="StoriesDate">
<h3>2018<span class="Chinese"> 年</span> 09<span class="Chinese">月</span> 28<span class="Chinese">日</span></h3>
</div>
<p>Hi. My name is Ragan, John Ragan to be exact - but please, call me JR. I'm a third year student who's currently attending Shanghai Jiao Tong University in pursuit of two B.S. in electrical and computer engineering in addition to a B.A. in Chinese</p>
</div>
</div>
<button class="button button5">
<h2>Previous</h2></button>
</section>
You may use this:
.StoriesBox2 + button:active {
display: block;
}
But it will only show the StoriesBox2 div when you click the button. If you want this div to be visible after click, you'll have to use JavaScript.

Color css property not affecting color of font awesome icons

I'm unable to change the color of the font awesome icons in our project (using the color property in css). I think the way we're loading our font awesome icons might be affecting our ability to change their color.
Before someone marks this as a duplicate, please take a look at the jsfiddle below.
You will see, from the html (at lines 7 and 10) that we're loading in a pre-defined set of fa icons from our own server. This is because, due to the nature of my organisation's work, we're not permitted to load external files.
https://jsfiddle.net/moosefetcher/dnjjy015/1/
Here is the html:
<div class="page">
<div id="fb-user-research">
<span class="fb-checkbox">
<input id="fb-user-research-checkbox" type="checkbox" name="fb-checkbox"/>
<label for="fb-user-research-checkbox" id="fb-visible-checkbox">
<svg class="unchecked fa-square-0">
<use xlink:href="~/Areas/CL/Content/app/images/icons/icon-svg-defs.svg#fa-square-o" />
</svg>
<svg class="checked fa-check-square">
<use xlink:href="~/Areas/CL/Content/app/images/icons/icon-svg-defs.svg#fa-check-square" />
</svg>
</label>
</span>
<div id="fb-user-research-texts">
<p>Placeholder text here</p>
<p>Disclaimer here.</p>
</div>
<div class="clear"></div>
</div>
</div>
And here's the css:
.page {
background-color: #000000;
height: 400px;
padding: 15px;
}
#fb-user-research {
border-radius: 3px;
border: 1px solid #333333;
margin: 44px 0px 14px 0px;
padding: 15px 15px;
}
#fb-user-research input {
border-radius: 2px;
background-color: #333333;
}
#fb-user-research input {
float: left;
}
#fb-user-research #fb-user-research-texts {
width: 90%;
float: left;
}
#fb-user-research div p {
margin-bottom: 4px;
}
#fb-user-research div p:first-child {
color: #ffffff;
}
#fb-user-research div p:last-child {
color: #888888;
font-size: 0.75em;
}
.fb-checkbox {
margin-right: 20px;
}
#fb-user-research #fb-user-research-texts {
width: 85%;
float: left;
}
.fb-checkbox > [type="checkbox"] {
width: 0;
height: 0;
display: none;
opacity: 0;
}
.fb-checkbox {
position: relative;
float: left;
margin-right: 10px;
}
.fb-checkbox > input[type=checkbox]:checked ~ #fb-visible-checkbox .checked {
display: inline-block;
opacity: 1;
color: #0099dd;
}
.fb-checkbox > input[type=checkbox]:checked ~ #fb-visible-checkbox .unchecked {
display: none;
opacity: 0;
}
#fb-visible-checkbox > svg {
position: relative;
top: 0px;
left: 0px;
width: 18px;
height: 18px;
cursor: pointer;
font-size: 18px;
}
#fb-visible-checkbox .unchecked {
background-color: grey;
color: #ffffff;
}
#fb-visible-checkbox .checked {
background-color: lightgrey;
color: #0099dd;
display: none;
opacity: 0;
}
.clear {
clear: both;
}
To be clear, when working in my dev environment, the icons load fine. The question I'm asking is:
Is loading the font awesome icons like we do (as shown in the jsfiddle) affecting our ability to change their color?
Thanks for any help!
You are not using the font version of the FontAwesome icons. You are using the SVG versions.
SVG doesn't use color to change the fill color of shapes. It uses fill.
You will need to at least change the CSS to using fill instead of color. You might also need to make other changes, but I can't tell you for sure because you haven't included your external SVG file.
Also, be aware that external <use> references, like you are using, don't work in IE (last I checked). You may need to inline your SVG in your HTML if you care about that.
I don't know if loading the font awesome icon affecting our ability to change their color, but you can change your text color by overriding its css property by adding this css:
#fb-user-research #fb-user-research-texts p{
color: red;
}
Try changing background-color of icons.
Since you use svg icons, it wont support color
If you are using <i class="fa fa-address-book-o" aria-hidden="true"></i> for implementing font awesome, you change the color by color: red

How to change the text color of a div on hover

I am trying to code a button that changes color when you hover over it/click on it. However, I ran into an issue. There is a space between the text and the edges of the div section, and if you hover over the button, it turns black but the text does not turn white. I put color:white;. I am not sure as to why this does not fix the problem.
Here is my code:
p {
margin: 0px;
}
.button {
width: 66px;
height: 20px;
border: 2px black solid;
border-radius: 4px;
padding: 5px;
}
.button:hover {
background-color: black;
color: white;
}
a {
color: black;
text-decoration: none;
}
a:hover {
color: white;
}
<div class="button">
<p> Click Me! </p>
</div>
just change your a:hover to .button:hover a
everything will look great. :>
p {
margin: 0px;
}
.button {
width: 66px;
height: 20px;
border: 2px black solid;
border-radius: 4px;
padding: 5px;
}
.button:hover {
background-color: black;
color: white;
}
a {
color: black;
text-decoration: none;
}
.button:hover a{
color: white;
}
<div class="button">
<p> Click Me! </p>
</div>
Ok so heres the deal. You made it too complex. If you had problem with the spaces, its because < a > tag is diplayed inline by default and it makes gap between it's container sometimes.
Here's your code, cleaned and working : https://jsfiddle.net/m6dphvm1/
<a class="button" href="https://www.google.com"> Click Me! </a>
a.button {
border: 2px black solid;
border-radius: 4px;
padding: 5px;
color: black;
text-decoration: none;
display: inline-block;
}
a.button:hover {
background-color: black;
color: white;
}
The problem with your CSS is that your anchor(link) color is black, when you hover on the button you are changing the background of button to black, i.e both anchor color and background are black. due to that text is not being visible.
Change either background-color of button or anchor color to a differnt color and that should work. For example I'm changing the color of anchor to blue.
.button:hover {
background-color: black;
color: white;
}
a {
color: blue;
text-decoration: none;
}
a is an inline element, meaning it's designed to be nested in plain text (or what otherwise could be). It's only occupying the immediate space around the text.
However, a tags are also totally allowed to wrap around elements according to the HTML5 spec (not that anyone would stop you otherwise, it's just convention). So if you want the a tag to occupy the entire space just wrap it around the element.
Better yet, only use the a tag. The rest is basically redundant:
<a class="button" href="https://www.google.com">
Click Me!
</a>
.button {
width: 66px;
height: 20px;
border-radius: 4px;
padding: 5px;
color: black;
border: 2px black solid;
}
.button:hover {
background-color: black;
color: white;
}
https://jsfiddle.net/hyp4a9ya/

Can't remove text decoration

Yes, I know this has been asked and answered but I can't get this working no matter what I try.
I need to remove the text decoration on a link that I have applied to a div.
The code looks like this:
#about-con a {
text-decoration: none !important;
}
div #about-con a:link {
text-decoration: none;
}
#about {
position: relative;
width: 100px;
height: 1.5em;
font-size: 1.125em;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
border: 1.5px;
border-style: solid;
border-color: black;
}
<div id="about-con">
<a href="http://ptunitedbrochure.bkm-tech.com/about.php">
<div class="inline-nav" id="about">
<div style="margin-top: 2px; text-align: center">
About Us
</div>
</div>
</a>
</div>
Instead of this:
div #about-con a:link {
text-decoration: none;
}
Place this:
#about-con a:hover{
text-decoration: none;
color: #337ab7;
}
This will make your link text stay the same on hover. Now, if you are talking about the border around the "About Us", you will have to remove border properties from your #about div.

Wordpress : Child-theme CSS weird behavior

I am currently customizing a wordpress theme.
Here my case, through a widget, I generate a div which has several classes :
<div class="col-lg-3 focus-box item-1">...</div>
The parent theme and bootstrap stylesheet already apply respectively properties on focus-box and col-lg-3 classes.
Well, I added to my child-theme stylesheet (which works well for many others things) this :
.item-1 { background-color: orange; }
And this does not work... nothing happen but I tried to do this in my child-theme CSS :
.col-lg-3 (or focus-box) { background-color: orange; }
.item-1 { background-color: orange; }
This way works... I really don't understand anything to what is happening here.
My Child-theme stylesheet is the last one to be load, so It should override all others, isn't it ?
If anyone has a clue, I would appreciate to get it :-)
Thanks in advance for your help.
Sommy
Thanks for your answers.
First, I already tried to use !important it didn't work, it was the same using stronger selector.
I know how to inspect code with my browser, and that's why I told you that my child-theme css was the last one to be loaded because I checked it.
The thing really weird, according to me, is that the result is different if I put col-lg-3 in my stylesheet or not.
I have similar issues with others HTML elements in my code.
To sum up :
My Child-Theme CSS is loaded after the parent-one
I checked it in my browser development tool
I also notice that the place where my CSS properties is change the result, if I put it at the end of my child-theme css it sometimes work example :
{
/* IF I PUT THE SELECTOR .focus-box .service-icon here It doesn't work */
/* SEE THE LAST ELEMENT BELOW */
.focus-box:nth-child(4n+1) .service-icon:hover {
border: 5px solid #e96656;
}
.focus-box:nth-child(4n+2) .service-icon:hover{
border: 5px solid #34d293;
}
.focus-box:nth-child(4n+3) .service-icon:hover {
border: 5px solid #3ab0e2;
}
.focus-box:nth-child(4n+4) .service-icon:hover{
border: 5px solid #f7d861;
}
.focus-box:nth-child(4n+1) .red-border-bottom:before {
background: #e96656;
}
.focus-box:nth-child(4n+2) .red-border-bottom:before {
background: #34d293;
}
.focus-box:nth-child(4n+3) .red-border-bottom:before {
background: #3ab0e2;
}
.focus-box:nth-child(4n+4) .red-border-bottom:before {
background: #f7d861;
}
.focus-box h5 {
margin-bottom: 15px;
color: #404040;
position: relative;
display: inline-block;
text-transform: uppercase;
margin-bottom: 30px;
font-weight: bold;
font-size: 17px;
float: none;
width: 100%;
background-color: rgba(224,82,6,0.2);
}
.other-focuses {
background: url(images/lines.png) repeat-x center;
margin-bottom: 25px;
}
.other-focuses .section-footer-title {
padding: 0 15px;
color: #404040;
font-weight: bold;
}
.other-focus-list {
padding-top: 5px;
margin-bottom: -17px;
}
.other-focus-list ul li {
display: inline-block;
margin-right: 50px;
padding-bottom: 15px;
text-transform: uppercase;
}
.other-focus-list ul li:last-child {
margin-right: 0;
}
.other-focus-list ul li i {
margin-right: 8px;
}
.item-dashboard {
padding: 20px 0 20px 0;
}
.focus-box p {
font-size: 14px;
color: black;
}
/* IF I PUT IT THERE THEN IT WORKS */
.focus-box .service-icon {
margin-bottom: 30px;
width: 145px;
height: 145px;
margin: auto;
border-radius: 50%;
border: 0px solid #ececec;
margin-bottom: 20px;
position: relative;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
Focus Box HTML Code :
<div class="col-lg-3 col-sm-3 focus-box item-dashboard" data-scrollreveal="enter left after 0.15s over 1s">
<div class="service-icon">
<a href="#">
<i class="pixeden" style="background:url(#/wordpress/wp-content/uploads/2015/10/cle_main_2.png) no-repeat center;width:100%; height:100%;"></i> <!-- FOCUS ICON-->
</a>
</div>
<!-- FOCUS HEADING -->
</div>
The question is why my child-theme CSS doesn't correctly override the parent one ? Why the place of my css element affect the result (I know the place affect if you override a property, but here it doesn't look like this...)
Thansk again for you help.
I finally overcame this issue by reviewing my style sheet loading priority and so on.
Thanks everyone.