Revealing hidden objects upon click of a button not working - html

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.

Related

How to create the expected button in 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>

How to make mobile responsive height of a div with variable list items?

I have created an HTML widget that I intent to publish on all posts on my WordPress blog.
The widget is looking fine on the browser, But it is looking a little shaky on the mobile screen.
<div class="top-box">
<h3 id="box-heading">Our Verdict</h3>
<p id="box-text">Considering its price point and the features it offers, the Sennheiser GSP 300 is absolutely a great choice. It might not serve
like the top-notch gaming headsets (which are really expensive too), it will not leave you disappointed for sure. <br /><br />The headset is
comfortable, sounds great, good-built, and is compatible with most platforms. With little cons like a non-detachable mic and no surround sound,
it still beats some other beasts of a bit higher price points. The light-featured Sennheiser gaming headset is just right for action-packed
gaming without burning a hole in your pocket.</p>
<div class="Sub-box">
<div class="sub-box-left"><span class="dashicons dashicons-yes-alt"> For</span>
<ul id="sub-box-text">
<li>Lightweight & comfortable</li>
<li>Crystal clear mic</li>
<li>Great noise-cancelation</li>
<li>Large volume dial</li>
</ul>
</div>
<div class="sub-box-right"><span class="dashicons dashicons-dismiss"> Against</span>
<ul id="sub-box-text">
<li>Non-detachable microphone</li>
<li>No surround-sound</li>
<li>No chat-game audio balancer</li>
<li>Cable can be a mess for console players</li>
</ul>
</div>
</div>
<div class="review-amazon">
<div class="top-star">
<p id="rating-text">Not On Top Rating</p>
[yasr_overall_rating size="medium"]
</div>
<div class="check-price">
<p class="price-check">Check Price</p>
<a class="amazon-button" href="#">Check Price on Amazon</a>
</div>
</div>
</div>
css
.top-box {
background-color: #ededed;
padding-right: 20px;
padding-left: 20px;
padding-bottom: 25px;
overflow: auto;
}
#box-heading {
font-weight: 600;
font-size: 16px;
line-height: 20px;
text-transform: uppercase;
vertical-align: middle;
}
#box-text {
font-size: 14px;
line-height: 1.5em;
margin-bottom: 10px;
color: #333;
}
.sub-box-left {
float: left;
width: 50%;
padding-left: 15px;
border-right: 1px #fff dotted;
}
.sub-box-right {
float: right;
width: 50%;
padding-left: 15px;
}
#sub-box-text {
line-height: 1.5;
list-style: none;
margin-bottom: 1rem;
margin: 0;
padding: 0;
padding-top: 25px;
border: 0;
font: inherit;
font-size: 15px;
padding-bottom: 20px;
}
.dashicons.dashicons-yes-alt,
.dashicons.dashicons-dismiss {
width: 100%;
text-align: left;
color: black;
font-weight: 500;
font-size: 17px;
line-height: 40px;
text-transform: uppercase;
vertical-align: middle;
}
p:empty:before {
display: none;
}
#yasr-custom-text-before-overall {
display: none;
}
.top-star {
float: left;
width: 50%;
}
.check-price {
color: black;
width: 50%;
float: right;
text-align: center;
}
.price-check {
text-align: center;
}
#rating-text {
text-align: left;
}
a.amazon-button {
background-color: #5eaf16;
padding: 7px;
color: white;
white-space: nowrap;
}
.review-amazon {
padding-top: 20px;
}
.sub-box {
padding-bottom: 10px;
}
https://notontop.com/review/headphone/sennheiser-gsp-300/
This is the sample URL where I have added the code.
[yasr_overall_rating size="medium"] is a shortcode for showing star rating for every product.
Please open the window and try changing the screen size.
You'll have to add a media query within the css and make the items, full width / no float on mobile.
Something Like:
#media only screen and (max-width: 600px) {
.check-price, .top-star {
width: 100%;
float: none;
clear: both;
margin-bottom: 20px;
}
.top-star div, #rating-text {
text-align: center;
}
}
I am not sure how this will work in Wordpress but for a responsive webpage created with HTML5 and CSS, you will need a meta tag at the head of the HTML document: This is used along with Media Queries in the CSS which will make your page responsive to any device and size screen from the mobile, laptop and desktop. This is done with #media then the size screen of the device you need.

There is a white space underneath the button in the detail box in html

I set the width of the parent element as 100%. Then, I decide the width of the two elements embraced by the parent one is at 50% each After that, I set the background color for the first one as white, and the other one as black. There is one weird white space under the first element. However I modified the size of the first box, it still remains there. Does anyone know how to remove that one?
.container {
width: 100%;
}
.infoBox {
width: 100%;
height: 400px;
margin: 0;
}
.detailBox {
width: 50%;
margin: 0;
padding: 0;
float: left;
font-size: 16pt;
background: black;
}
.detailBox2 {
width: 50%;
margin: 0;
padding: 0;
float: right;
font-size: 16pt;
background: white;
}
.post {
width: 90%;
padding: 0 5%;
}
.detailBox .post {
color: white;
}
.detailBox2 .post {
color: black;
}
.post h1 {
margin: 2% 0;
}
.detailBox button {
padding: 4.65% 12%;
background: white;
border-radius: 30px;
color: #688dc1;
font-size: 10pt;
border: none;
border-color: #688dc1;
letter-spacing: 0.04em;
text-align: center;
font-weight: bold;
}
.detailBox2 button {
padding: 4.65% 12%;
background: white;
border-radius: 30px;
color: #688dc1;
font-size: 10pt;
border-color: #688dc1;
letter-spacing: 0.04em;
text-align: center;
font-weight: bold;
}
<div class="container">
<section id="infoBox">
<section class="detailBox">
<div class="post">
<h1>About me</h1>
<p>I studied editiorial, graphic, Western Art, web design and developement at college in Canada. After working at an American and Canadian companies, I finally established my own design comapny, JoeyNamiki Design. I discovered that I want to create
a large range of designs. In addition, I also want to develop as many websites as I can. </p>
<button>Learn More</button>
</div>
</section>
<section class="detailBox2">
<div class="post">
<h1>About you</h1>
<p>If you are looking for a web agency that can redesign and create your company's website with a well-ordered process, you should ask me what you want to do through email. With a clear menu, you can immediately tell how much are the costs for your
website and other options such as graphic, logo, poster designs. Let's talk together about your future website!</p>
<button>Learn More</button>
</div>
</section>
</section>
Change width as i changed width: 30%;
Try below snippet.
.container{
width: 100%;
}
.infoBox {
width: 100%;
height: 400px;
margin: 0;
}
.detailBox {
width: 30%;
margin: 0;
padding: 0;
float: left;
font-size: 16pt;
background: black;
}
.detailBox2 {
width: 50%;
margin: 0;
padding: 0;
float: right;
font-size: 16pt;
background: white;
}
.post {
width: 90%;
padding: 0 5%;
}
.detailBox .post {
color: white;
}
.detailBox2 .post {
color: black;
}
.post h1{
margin: 2% 0;
}
.detailBox button {
padding: 4.65% 12%;
background: white;
border-radius: 30px;
color: #688dc1;
font-size: 10pt;
border: none;
border-color: #688dc1;
letter-spacing: 0.04em;
text-align: center;
font-weight: bold;
}
.detailBox2 button {
padding: 4.65% 12%;
background: white;
border-radius: 30px;
color: #688dc1;
font-size: 10pt;
border-color: #688dc1;
letter-spacing: 0.04em;
text-align: center;
font-weight: bold;
}
<div class="container">
<section id="infoBox">
<section class="detailBox">
<div class="post">
<h1>About me</h1>
<p>I studied editiorial, graphic, Western Art, web design and developement at college in Canada. After working at an American and Canadian companies, I finally established my own design comapny, JoeyNamiki Design. I discovered that I want to create a large range of designs. In addition, I also want to develop as many websites as I can. </p>
<button>Learn More</button>
</div>
</section>
<section class="detailBox2">
<div class="post">
<h1>About you</h1>
<p>If you are looking for a web agency that can redesign and create your company's website with a well-ordered process, you should ask me what you want to do through email. With a clear menu, you can immediately tell how much are the costs for your website and other options such as graphic, logo, poster designs. Let's talk together about your future website!</p>
<button>Learn More</button>
</div>
</section>
</section>

Background and hover effect

I'm trying to make the above text (home help customer etc) similar to the one below Home and all in green box with white text and hover effect but I am unable to add the green background and make the words display similar to the once below with a hover effect I have tried some things out but it did not help me out and also I have tried a lot to move the cart to the top right to make it look like a normal shopping website but it didn't work if you guys see any mistakes or suggestions to make it better I would really appreciate it as I am a beginner https://imgur.com/2Bhxzs2
Help fix the top header please refer the image link as it shows were exactly is the green box and all thank youthe image has the header of the website were there are different buttons like guest customer help etc and I am trying to make it like the one underneath in the green box with a hover effect
<html>
<head>
<title>Rajeshri Traders </title>
<link href="CSS/style.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="subheader">
<div class="container">
<p> CCTV Supplier</p>
Guest Consumer Download App
Help
</div>
</div>
<!--==main header==-->
<div id="main-header">
<!--logo-->
<div id="logo">
<span id="ist"></span><span id="iist"> Rajshri Traders</span>
</div>
<!--==search area==-->
<div id="search">
<form action="">
</form>
<input class="search-area" type="text" placeholder="Search here">
<input class="search-btn" type="submit" value="SEARCH">
<!--="user-menu"==-->
<div id="user menu">
</div>
<li>Cart
<li>Login
</div>
</div>
</div>
<!----=====navigation bar==--->
<div id="navigation">
<nav>
Home
New Arrivals
Products
Deals
Accesories
Order
</nav>
</div>
</div>
</body>
</html>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
#wrapper {
font-family: tahoma;
}
/*logo styling*/
#main-header {
width: 100%;
height: 125px;
background: #93A7FF;
display: flex;
flex-wrap: no-wrap;
}
#main-header > div {
flex: 1 1 0;
}
#ist {
color: black;
font-size: 65px;
font-weight: bold;
margin-left: 15px;
font-family: fantasy;
}
#iist {
color: black;
font-size: 45px;
font-weight: bold;
margin-left: 15px;
font-family: fantasy;
}
/*searchinga area styling*/
#search {
padding: 20px;
margin-left: 50px;
text-align: center;
}
.search-area {
width: 350px;
height: 30px;
background: #fff;
border: none;
border-radius: 10px;
padding-left: 15px;
}
.search-btn {
width: 65px;
height: 34px;
border-radius: 10px;
border: none;
color: #fff;
background: brown;
margin-left: 15px;
}
/*this is for user menu styling*/
#user-menu {
margin-top: 20px;
margin-right: 20px;
text-align: right;
}
#unser-menu ul {
list-style-type: none;
width: 100%;
}
#user-menu li {
display: inline-block;
padding: 0px 10px;
}
#main-header > div {
flex: 1 1 0;
}
/*this style is for navigation bar */
#navigation{
width: 100%;
height: 35px;
background: #1aaa1a;
float: left;
box-shadow: 10px 14px 45px 3px #1aaa1a;
}
nav{
width: 1200px;
margin: 0 auto;
}
nav a{
margin-left: 35px;
color: white;
text-decoration: none;
}
nav a:hover{
color:#000;
transition: all .7s ease;
}
To give a background colour to your 'home, help, customer etc' text, you need to refer to the element in which they are all included. In this case, they are all contained within the .container class. So by adding styling to the .container class, you'll be adding styling to the div containing the text in question.
Simply add a background colour to the .container class like this:
.container {
background: #1aaa1a;
}
As for the hover effect, you can specify the effect you want for each link of the 'home, help, container etc'. For example, if you want to change the colour of the text when you hover on it, you can do something like this
.container a:hover {
color: black;
}
The .container a is how you reference the links contained in your .container class.
Alright.So you need to see what styling you have applied to the text in the green box. you need to copy the styling you use in #navigation which is the container for everything in the green box. You have included your links in the green box in a nav element, you have then styled the nav element as follows:
nav{
width: 1200px;
margin: 0 auto;
}
nav a{
margin-left: 35px;
color: white;
text-decoration: none;
}
nav a:hover{
color:#000;
transition: all .7s ease;
}
You need to style your links in the .container div in the same way. The easiest way to do this would be to include your home, help, customer links in a nav element as follows:
<div class="container">
<p> CCTV Supplier</p>
<nav>
Guest Consumer
Download App
Help
</nav>
</div>

How to position close button correctly

everyone! I am a long time web developer and designer, but this one has me dumbfounded. I have an alert (this is not Bootstrap) with a close button. It displays fine on the home page:
But when I put the same alert on the submit page, it moves the close button down:
Any ideas? Here's my HTML:
<div class="alert">
<div class="alertContents">
When you submit yo stuff, it comes up in the feed right away.
<div class="alertClose">×</div>
</div>
</div>
And CSS:
.alert {
width: 100%;
background-color: #DD7474;
font-family: 'Raleway', sans-serif;
font-size: 18px;
color: #FBFBFC;
margin: auto;
border-radius: 2px;
border-color: transparent;
border-width: 0px;
border-style: solid;
}
.alertContents {
padding-top: 4px;
padding-bottom: 4px;
padding-left: 10px;
padding-right: 10px;
}
.alertClose {
float: right;
width: auto;
height: auto;
color: #FBFBFC;
cursor: hand;
}
Thanks!
.alert {
position:relative;
}
.alertClose {
position:absolute;
top:5;
right:5;
}
this is probably what you need.
check out #4 on this link http://www.barelyfitz.com/screencast/html-training/css/positioning/
I would use:
position: absolute;
and then add in the
left: 250px;
EDIT: Add those codes to your css... Ohh and looking back at what was happening, you could maybe make sure there is a:
clear: both;
function like:
<div class="clear"></div>
or
<br clear="all" />