I'm new to html/html5, but not to programming, and i'm trying to code my personal website. I've read many resources and tutorials on the basics but I'm looking for some tips on how to begin achieving the layout I want.
In my layout (here) I'm looking to have the left half of my page as a fixed navigation panel with an image highlighting the current page, then with each option the right side refreshes to a new independently scrolling page and the highlight image animates in the nav panel to the new option.
How should I begin to achieve something like this? I just need a push in the right direction to the type of elements/scripts/whatever I will need to implement.
Thank you!
Here is a simple example to help you start out:
jsFiddle
You'll notice the text on the right slides out of the screen when you scroll but the green box stays in the same position. This is done with a slight bit of CSS.
The navigation div on the left is styled with position: fixed;. This keeps the navigation div in one place at all times.
In contrast, the content div on the right is styled with position: absolute; with a left: 25% set. The widths of the navigation div and content div are set in percentages. This allows the content to take up the same relative screen space whether the window is larger or smaller. Your content will adapt to your viewers resolution.
Using an <iframe> will is one possible solution to altering the content in the right hand content div. Another would be to use ajax but that is getting a little more advanced as you now must understand client and server scripting in order to receive the full benefits from it.
iFrame
Ajax
If you're information is static and will not change often, you could considering making a single page web app with multiple templates that are appended to the content div.
jQuery
jQuery Templates Plugin
jQuery is really good as well for learning JavaScript and makes building dynamic client side applications a breeze.
They also have ajax support as well:
jQuery Ajax
Hope this helps.
Good luck and Happy Coding!
You have the menu housed within an element that is set to position: fixed;
Position fixed will make sure the menu doesn't move around on the page regardless of scrolling the rest.
Then with javascript you can add an event listener for "scroll" on the window (or just the div you want to watch for scrolling). When this fires, check the scrollY property to see what range it is in and maybe highlight certain items in your menu.
Hopefully this leads you down the right path. It's a broad question, so here's a broad answer!
I second the suggestion from #Jeromy French -- I think Bootstrap , Foundation and other responsive frameworks have a lot going for them.
Here's an example using Bootstrap: http://jsfiddle.net/panchroma/2dF6s/
In addition to being HTML5, you can get a layout which works on everything from smartphones to wide desktops. It's not the only way to get a mobile friendly website, but it's one of several good options.
I think that with so much moving towards smartphones and tablets now, the more you can learn about responsive and mobile websites, the better off you will be in the future.
I think all the responsive frameworks use a grid based system, here's what the HTML looks like with Bootstrap:
<div class="container">
<div class="row-fluid" align="center">
<div class="span12">
<h1>Header</h1>
</div><!-- close span12 -->
</div> <!-- close row -->
<div class="row">
<div class="span3" id="side-nav" data-spy="affix" data-offset-top="200">
<h5>Option 1</h5>
<h5>Option 2</h5>
<h5>Option 3</h5>
<h5>Option 4</h5>
</div> <!-- end span3 -->
<div class="span9">
<p>Main Content Here </p>
</div> <!-- end span9 -->
</div><!-- end row -->
</div><!-- end containter -->
Good luck!
Related
I have been using Bootstrap for some time, and it gave me a chance to practice CSS and do some landing pages. The thing is, Bootstrap comes with a lot of classes already declared. You don't have to worry about layout and all the stuff (as you all already know that). I started practicing HTML/CSS but without Bootstrap.
In Bootstrap I always had that pattern :
<div class="container">
<div class="row">
<div class="col-12">
Content
</div>
</div>
</div>
That gave me a chance to have everything inside of a precompiled container and didn't have to worry about layout.
Now I'm having some trouble understanding how should my structure look like when I don't use Bootstrap, in a let's say landing page where every section has the same margin and everything is contained inside of bootstrap-like container with margins on left and right sides.
How should I do my CSS and containers to have a good layout for a landing page?
You can easily do CSS and containers to have a good layout for a landing page. Infact you can be good at it in max 2 days. CSS Web Layouts , It is all you need to practice and be good at it asap.
I am building a small blog based on metalsmith and the PureCSS framework, which has a simple three-row-layout like so:
<div class="pure-g">
<div class="pure-u-1"> Navbar </div>
<div class="pure-u-1"> Content </div>
<div class="pure-u-1"> Footer </div>
</div>
As I am still learning a lot new stuff about CSS and responsive design I am wondering if a navbar should be put into a grids row as well or if it should reside outside of it. The PureCSS documentation states the following:
All content which is visible to people needs to be contained inside a
grid unit. This ensures that the content will be rendered properly.
This would make it a yes, as a navigation menu is of course visible to the user. However doesn't that make handling of media queries more complicated for the navbar? So where should I put my navbar to, when using responsive grids?
No. Navbar should not necessarily be within the grid. The main purpose of using grids is to make the content look better and proper. It also aids the programmer in deciding how many blocks of the grid to allot to a certain element.
However, since a Navbar goes all the way across the page, there is no reason to assign it a grid size. It should always be 100%.
If you are building a blog app, then only your content should be within your grid system so as to properly render the elements. From what I've seen, a footer also generally stretches all the way across the window.
You can use grid. Managing and handling contents and components would be easier and rendering in different browsers would be more stable.
I am using Twitter bootstrap for my portfolio site. The fluid layout seems to work up to a certain point, but there are a few issues with the home page.
Once I go smaller than about 997px, the nav menu disappears entirely. It almost looks like it drops down below the header bar and is hidden, but I can't seem to get it to show. It should actually switch to the mobile menu and remain in the upper right corner.
Also once you get down to smaller screen sizes, the "About Me" and "Contact" sections of the index page overlap each other. I'm sure this has to do with my structure somehow, but cannot find the problem.
Any bootstrap experts know what might be causing these issues?
Here is a link to the test version of the site. http://theiamzone.com/kyle_hagler/portfolio-site
From the source code I view from the site,
I Found out that you lacked of jquery file.
<script src="//code.jquery.com/jquery-1.10.1.min.js">
Put it and see if the dropdown work.
And for the About Us and Contact Us part.
A method you can try is put container to wrap them all, read from here for more information.
http://twitter.github.io/bootstrap/scaffolding.html#layouts
From my point of view in about us section, try no to wrap the 2 span 6 column,
Use the following code instead.
<div class="row-fluid">
<div class="span12">
<div class="span6"></div>
<div class="span6"></div>
</div>
</div>
Same situation happen on the contact us section,
the css class aren't assigned for them to work.
I built a standalone app using angular, and it was responsive (I didn't do any work, just used row-fluid, etc). However, now I'm preparing to install this standalone app into an existing site built in a different language. I bootstrapped a div with angular, and applied Twitter Bootstrap css only to that div.
Then, I used JQuery UI and some angular wrapper directives to make the div where the app lives draggable, droppable, and resizable. I ran into a problem when I started resizing the div, though. The built in responsive design responds to the size of the overall window, not the size of the div.
Sorry about the bad CSS inline styling; I'm still just hacking around to make it work. Here's my code right now -- would love it if anyone had some input.
The partials just have some forms in row-fluid tags, and some tables.
The whole point is that it's a tool that sits in the corner that is pretty small but can be expanded to show a fuller view. Everything needs to fit when it is small, though.
<div draggable droppable resizable class="bootstrapped" ng-app="myApp" id="ambatool">
<div id="handle" style="background-color: gray; height: 50px; cursor: move"></div>
<div style="padding:20px" class="container" id="maintool">
<div ng-view>
</div>
<ul class="nav nav-tabs">
<li>Detail</li>
<li>Queue</li>
</ul>
</div>
<div id="dock"></div>
What you're looking to achieve is the next step in responsive design and doesn't exist "out of the box". Rather than viewport media queries you need element media queries, where the contents of a div react to the size of it's container within the viewport, rather than the viewport itself.
The filament group has written an article about how to implement some workarounds... in the future.
Smashing Magazine recently wrote Media Queries Are Not The Answer: Element Query Polyfill which show you how you can use the Element Query polyfill to do just what you are after.
I am working on converting a twitter bootstrap theme into a wordpress theme and adding onto it.
I am having issues adding full width items into the theme. I have tried adding a slider plugin that is set to full width. Although when it is added it goes to a fixed width, the same happens if I add an image aswell. It seems all of the content in my page does this except for my header and footer.
Also it seems every time I add in anything to the page the page/footer gets messed up. I am still learning css though.
I am posting a link to the site to see if anyone can take a look and give me a hand.
http://goo.gl/8JUDA
It looks like you contained the element that you want to stretch the size of the window within a .container div.
.container is used in bootstrap for fixed layouts. Instead try using the .container-fluid class.
For example:
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<!--Sidebar content-->
</div>
<div class="span10">
<!--Body content-->
</div>
</div>
</div>
Read more: http://twitter.github.io/bootstrap/scaffolding.html#layouts