Is it possible to have sidenav start open in W3.CSS? - css

W3.CSS is a very new web technology and I cannot find any information about it other than w3schools.com. I was wondering if anyone here knows how to have their sidenav start out open?
Here is a working example that shows one in action:
https://jsfiddle.net/8orgp5xv/
#import 'http://www.w3schools.com/w3css/w3full.css';
<nav id="id01" class="w3-sidenav white w3-depth-2">
Close ×
Link 1
Link 2
Link 3
Link 4
Link 5
</nav>
<div class="w3-content">
<div class="w3-header teal">
☰
<h1>My Header</h1>
</div>
<img src="img_car.png" alt="Car" width="100%">
<div class="w3-panel">
<p>
A car is a wheeled, self-powered motor vehicle used for transportation.
Most definitions of the term specify that cars are designed to run primarily on roads,
to have seating for one to eight people,
to typically have four wheels. (Wikipedia)
</p>
</div>
<div class="w3-footer teal">
<h5>Footer</h5>
<p>Footer information goes here</p>
</div>
</div>
I just need to know how to make it start open when the page loads.
I tried messing with w3-sidenav and w3-closenav with no luck. Anyone know?

The relevant bit of code appears to be:
.w3-sidenav:target {
width: 25%;
display: block;
}
.w3-sidenav:target + .w3-content {
margin-left: 25%;
}
.w3-sidenav:target + .w3-content .w3-opennav {
display: none !important;
}
.w3-sidenav:target + .w3-content .w3-closenav {
display: block !important;
}
This means that the navigation show/hide and the surrounding layout changes are driven by CSS :target and hash fragments. Which means unless you rewrite or duplicate these rules and use .w3-sidenav:not(:target) and change the a element triggering the sidenav, or something similar, it's going to be difficult to tell the layout to load with the sidenav open in pure CSS.
Needless to say, this is made trivial by either setting the appropriate hash on page load, or better yet, rewriting the entire component to use JavaScript instead of hash fragments and :target.

First, W3.CSS is not a "very new web technology". It's just a stylesheet.
If you want to know how to use it, see the documentation of the authors, or learn CSS to understand it directly.
In this case, the code that opens the sidenav is
.w3-sidenav:target {
width: 25%;
display: block;
}
The :target is a pseudo-class that matches the element whose ID (or name) equals the fragment identifier (the part of the URI after #).
Therefore, you should use some JS to set the fragment identifier to the id of the element when the page loads. This can be done using hash:
document.location.hash = 'id01';
document.location.hash = 'id01';
#import 'http://www.w3schools.com/w3css/w3full.css';
<nav id="id01" class="w3-sidenav white w3-depth-2">
Close ×
Link 1
Link 2
Link 3
Link 4
Link 5
</nav>
<div class="w3-content">
<div class="w3-header teal">
☰
<h1>My Header</h1>
</div>
<img src="img_car.png" alt="Car" width="100%">
<div class="w3-panel">
<p>
A car is a wheeled, self-powered motor vehicle used for transportation.
Most definitions of the term specify that cars are designed to run primarily on roads,
to have seating for one to eight people,
to typically have four wheels. (Wikipedia)
</p>
</div>
<div class="w3-footer teal">
<h5>Footer</h5>
<p>Footer information goes here</p>
</div>
</div>

Related

Hiding #text in a /div wordpress theme homepage

We run a site with WordPress and use a template for our design.
On our homepage we have a scroll of our blog posts that includes a title, author/post info, reading time and an "excerpt"?
We're trying to get rid of the "excerpt"
blog-post-content-list-sider is the div and the text is just a #text within.
Everything I've looked up is something like .blog-post-content-list-sider { display: none; } but that would hide the entire thing not just one aspect of it (if I understand correctly)
This is the code for 1 blog-post-content-list-sider
The part that starts with "A Cutting-Edge" is the text that I need removed from each post on our page.
<div class="blog-post-content-list-sider">
<div class="textalignleft subtitle_post_standard">
Artificial Intelligence Emerging Technology Medicine</div> <h3 class="title_post_standard"> AI: The Key to Fertility Treatment? </h3>
<div class="fancy_one ig_meta_post_classic textaligncenter">
<span><div class="indie_author">By <b> <div class="vcard author">
Sohail Merchant</div> </b>
</div><div class="indie_on">on </div><div class="updated indie_date"> <b> August 30, 2020</b> </div> </span></div>
<span class="rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time">4</span> <span class="rt-label rt-postfix">minutes</span></span>
A Cutting-Edge Discussion about AI’s Eminent Role in Reproduction Intro Artificial intelligence has been widely useful in the diagnosis and treatment of diseases. However, little has been discovered about its capabilities in the realm of fertility treatment. Well, all that is about to change because we will soon experience the first application of AI in […]
</div>
EDIT:
I tested this CSS code and it works. Codepen link here
Please try
.blog-post-content-list-sider{
visibility:hidden;
}
.blog-post-content-list-sider>*{
visibility:visible;
}

Project Clarity - Fixed Navigation

I'm trying to create a fixed Navbar using Project Clarity
I'm using it in my Angular project, they are using FlexBox, I have tried putting in position: fixed but it doesn't seem to work, anyone have any ideas ?
<clr-header class="header-6">
In order to fix the header so that content scrolls underneath it, your application needs to have the correct Application Layout. Our components work within this structure because A properly structured layout enforces an optimal, consistent experience across applications.
The general structure for A Clarity Application layout takes this form:
<div class="main-container">
<div class="alert alert-app-level">
...
</div>
<header class="header header-6">
...
</header>
<nav class="subnav">
...
</nav>
<div class="content-container">
<div class="content-area">
...
</div>
<nav class="sidenav">
...
</nav>
</div>
</div>
Obviously, you can get rid of the parts that may not be relevant to your app like: alert-app-level, subnav etc ...
You can see this working in a quick demo I made with inspiration from Bob Ross. As you can see the content scroll underneath the application header.
if someone has also either very this problem, or another problem where some css does not work within Angular:
Since we mostly structure our UI code in multiple components in Angular, and since each component puts its own host-tag in the generated DOM between the actual html tags, the clarity library has some problems with it.
So as a workaround, if you still want to be able to keep your current htmls as they are, you can define this css in each your component's css file:
:host { display: contents; }
This causes the component's box not to render; means the host tags are still visible in DOM, but they will not have any effect regarding CSS. And any clarity CSS will work again.

why doesn't this simple bulma example work? (straight from their site)

I copied a basic example from the site and included the css file, but the columns aren't being styled. What am I missing?
https://jsfiddle.net/bLm2rgoz/6/
Here's the template:
<div class="columns">
<div class="column">1</div>
<div class="column">2</div>
<div class="column">3</div>
<div class="column">4</div>
<div class="column">5</div>
</div>
Of course, I'm including https://cdnjs.cloudflare.com/ajax/libs/bulma/0.2.3/css/bulma.css
This will only address the responsiveness of the 5 columns! You can demonstrate the responsiveness by widening and shrinking the fiddler-view. (Hint: Drag the left-side of the view panel to do so)
Expected & Observed: row of 1 2 3 4 5 when the view is wide, column of
1
2
3
4
5
when the view is not wide.
If you're trying to style the columns, please be more specific on which styles you want : )
It doesn't work because they are not even using the same CSS library they tell you to use to get that result (and yes, that sucks!)
If you view the source code on the example site, you see that it is actually:
<p class="bd-notification is-primary">First column</p> and not just First column.
So we edit our HTML and it still doesn't work. So back to the source and we discover that the CSS being referenced is in bulma-docs.min.css, and not in the CSS from the CDN or download that you are told to use (which is just bulma.min.css or bulma.css).
So we look at that and add some new CSS to the <head> of our HTML...
<style>
p.nice {
background-color: #00d1b2;
color: white;
border-radius: .375em;
font-weight: 600;
padding: 1.25rem 0 1.25rem 0;
position: relative;
text-align: center;
}
</style>
and change the example to be like this...
div class="columns">
<div class="column"><p class="nice">First column</p></div>
<div class="column"><p class="nice">Second column</p></div>
<div class="column"><p class="nice">Third column</p></div>
<div class="column"><p class="nice">Fourth column</p></div>
</div>
and then it finally looks like the example on the web site.
Dear library/framework developers... We love you and the work you do, especially when you document it and make nice examples. But when you claim using your framework is "very simple" and "just copy this code", then the result should look the same as your example. Don't use different code to what you are putting in the example, unless you also state very clearly that it will look/act differently and why. Remember, even experienced programmers are "newbies" to your framework, and having to waste time trying to figure out why it isn't working like the example can be really infuriating.

How can I ensure that my Jumbotron doesn't resize after loading new content that is smaller/larger?

I am currently working on earning the Front End Development certificate on FreeCodeCamp, and I am trying to improve some of my older projects. I created a random quote generator that pulls a quote from an API.
When the quotes are populated, the length of the quote can vary, so from time to time the Jumbotron that contains the quote/author will resize to account for that. I don't like this, as it looks jumpy to me when it does happen. My goal, ultimately, is to make sure that the box stays the same size no matter what quote is populated, even before one has loaded.
Would it be possible to set a minimum size for it that is slightly larger than any of the quotes will be (maximum quote length is 136 characters)?
HTML:
<div class='container'>
<div id='jumbo' class='jumbotron' style='min-height: px'>
<h1>Quote Machine</h1>
<hr></hr>
<p id="quote"></p>
<p id="author"></p>
<button id='icon' class="btn btn-custom btn-block">I'll Have Another!</body>
</div>
CSS (that applies to this situation):
.jumbotron {
background-color: #1abc9c;
}
.container {
padding: 30px;
}
Link for reference
Thank you!

How do I customize the CSS of just my FIRST post on archive/home pages?

So I've done a lot of research before asking this question. I already know how to use the if/else and conditional tags to make certain code applicable to only certain pages, BUT, I noticed that there isn't a single guide or question-answer out there addressing my question on only styling the first/most recent post in my blogger.
The closest I got to finding the solution (other than codes that I didn't have the skill to implement), was this one: http://helplogger.blogspot.ro/2014/01/create-magazine-style-layout-for-blogger-posts.html
Sample site from that tutorial: http://helploggertestblog.blogspot.com/
The problem with the above script is that was made to be too automated, and I don't need a post-summary or thumbnail for my other posts-- I'm only trying to change the look for the first post. I love that the first post's width was increased, bordered, color-changed, and what not.
Does anyone have any ideas on how I might isolate what I'm looking for, point me towards the right direction, or even hand me a general container so that I can get on with my life?
Without seeing any of your code it's kinda guessing, but I'll give it a try anyway.
I'm guessing that you have the posts in a div or other parent element. Something like this:
<div class="container">
<div>
<h3>Title</h3>
<p>Content of the post ... </p>
</div>
<div>
<h3>Title</h3>
<p>Content of the post ... </p>
</div>
<div>
<h3>Title</h3>
<p>Content of the post ... </p>
</div>
</div>
To style only the first div inside the container, you can use:
.container > div:nth-first-child {
/* your specific style here */
}
With your code, it would be easier to help...
EDIT
Use:
.blog-posts > .post-outer:first-child {
background: green;
}
There is a conditional tag available for 1st post
<b:if cond='data:post.isFirstPost'>
Your custom css only for the 1st post here
</b:if>

Resources