I'm new to HTML and CSS and to improve my skills i've been trying to recreate differnt sites by myself. I'm currently trying to recreate the notion home page but i have an issue. my img div is not centring? This is probably an easy fix but if someone could help i'd apprectiate it :)
Here is my HTML:
#import url("https://fonts.googleapis.com/css2?family=Inter:wght#400;500;700&display=swap");
:root {
--primary-text: #111111;
--secondary-text: #91908f;
--background: #fffefc;
--btn-primary: #e16259;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: var(--b);
font-family: "Inter", sans-serif;
}
/* NAV */
.nav {
width: 100;
}
.logo {
max-width: 100%;
height: 55px;
margin-right: 70px;
margin: 15px 50px;
}
a,
a:link,
a:visited {
color: #111111;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.nav ul {
display: flex;
padding: 35px;
list-style: none;
}
.nav ul li {
padding-right: 20px;
text-decoration: none;
color: #91908f;
}
.nav {
float: right;
}
/* HERO */
.nav-img {
display: flex !important;
align-items: center;
justify-content: center;
}
<img class="logo" src="img/logo.png" alt="Notion Logo">
<div class="nav">
<ul>
<li>Product</li>
<li>Download</li>
<li>Resources</li>
<li>Pricing</li>
<li>Careers</li>
<li><span>|</span></li>
<li>Sign Up</li>
<li>Log In</li>
</ul>
</div>
<div class="hero">
<div class="hero-img">
<img src="img/hero.webp" alt="Illustration of 3 people using laptop computers on seperate desks with different expressions">
</div>
<h1>All-in-one workspace</h1>
<h4>One tool for your whole team. Write, plan, and get organized.</h4>
<form action="">
<input type="text" placeholder="Enter your email...">
<button class='btn-primary' type="submit">Sign Up</button>
</form>
<p>For teams & individuals - web, mobile, Mac, Windows</p>
</div>
..
There are different things you need to consider when learning to code, first of all, it's important to use the new html5 semantic element header where you can place your logo and nav
<header>
<img src="logo.png" alt="Notion Logo">
<nav>
Product
Download
Resources
Pricing |
Careers
Sign Up
Log In
</nav>
</header>
*note: a nav element doesn’t have to contain a list as mentioned in MDN, and you can style them easily. The img centering issue came from the header wrong styling .nav{float: right;} .nav{ width: 100} needs to have px, %, or vw example .nav{width: 100px;}, .nav{width: 60vw;}, .nav{width: 60%;} then you can easily center the other elements vertically like below
.center-vertically {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
<header>
<div class="header-sub">
<img class="logo" src="img/logo.png" alt="Notion Logo" />
<nav>
Product
Download
Resources
Pricing |
Careers
Sign Up
Log In
</nav>
</div>
</header>
<div class="center-vertically">
<div class="centered-item">
<img src="https://www.notion.so/cdn-cgi/image/f=auto,w=1080,q=100/front-static/pages/product/hero.png" alt="Illustration of 3 people using laptop computers on seperate desks with different expressions" />
</div>
<h1>All-in-one workspace</h1>
<h4>One tool for your whole team. Write, plan, and get organized.</h4>
<form action="">
<input type="text" placeholder="Enter your email..." />
<button class="btn-primary" type="submit">Sign Up</button>
</form>
<p>For teams & individuals - web, mobile, Mac, Windows</p>
<div class="centered-item">anything you want to add</div>
</div>
You can style your header, and there is an awesome resource to follow to learn properly Freecodecamp
Related
I have written the following HTML code :
My main focus is to align the list items - HOME | All About Kittens | Feeding Your Kitten
properly. It's currently appearing as a simple list. I want to make it like :
Here the list items are Home, Shop and collections and they are aligned horizontally
Plus when you hover over an item it changes in color and a line appears below it
Any ideas how should I go about implementing this way
a {
color: black;
text-decoration: none;
}
.promo_banner {
background-color: #333;
text-align: center;
color: #fff;
font-size: 12px;
position: relative;
width: 100%;
z-index: 5000;
top: 0;
overflow: hidden;
}
div.logo img {
max-width: 205px;
width: 100%;
margin: 0 auto;
display: block;
max-width: 100%;
height: auto;
}
<html>
<head>
<link rel="stylesheet" href="home.css" />
</head>
<div class="promo_banner">
<div class="promo_banner__content">
<p>
<strong>Our Guide on Caring for Your Furry Feline Friend</strong>
</p>
</div>
<div class="promo_banner-close"></div>
</div>
<div class="top_bar clearfix">
<ul class="social_icons">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<div class="container">
<span><i class="fab fa-twitter"></i><a href="https://www.twitter.com"></span>
<span><i class="fab fa-facebook-f"></i></span>
<span><i class="fab fa-youtube"></i></span>
<span><i class="fab fa-instagram"></i></span>
</div>
</ul>
</div>
<div class="logo text-align--center">
<a href="https://store.linefriends.com" title="LINE FRIENDS INC">
<img
src="logo.jpeg"
class="primary_logo lazyloaded"
alt="LINE FRIENDS INC"
/></a>
</div>
<div class="nav">
<ul class="menu center">
<li >
<span>HOME</span>
</li>
<li >
<span>All About Kittens</span>
</li>
<li >
<span>Feeding Your Kitten</span>
</li>
</ul>
</ul>
</div>
</html>
This is the logo.jpeg I am using in the HTML.
I wanted to make it like How the image line items appears in middle
You can use display: flex; to show navigation like the UI you mentioned.
Here's the demo: https://codepen.io/shubhamp-developer/pen/gOmmxOg
.nav .menu{
display: flex;
list-style: none;
}
Preview:
To learn more about display flex, I would prefer to follow this super helpful link: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Basically these two properties will fix this.
display: flex;
justify-content: center;
Add these classes and remove background color from .nav .menu
.nav .menu{
display: flex;
gap: 1rem;
list-style: none;
}
.nav{
display: flex;
justify-content: center;
}
.nav_wrapper {
background: #f1f1f1;
}
Also wrap your <div class="nav"></div> in another div.nav_wrapper
<div class="nav_wrapper">
<div class="nav">
</div>
</div>
so I am trying to set all the margins and the paddings for the upper part to 0 then add padding and margin to the elements individually whenever I need to that's why I would like to override the color and the margin set by the universal selector * but it doesn't work, everything is staying deeppink and also the margin doesn't change, please help.
/*------------------------All Margin & Padding-------------------------*/
.upperPart {
margin: 0px;
padding: 0px;
background-color: darksalmon;
}
.upperPart * {
margin: 0px;
padding: 0px;
background-color: deeppink;
}
body {
margin: 0px;
padding: 0px;
}
/*-----------------------------------Colors-------------------------*/
header {
background-color: darkolivegreen;
}
h1,
h2,
h3 {
background-color: mediumspringgreen;
}
nav {
background-color: teal;
}
ul {
background-color: magenta;
}
li {
background-color: yellow;
margin: 5px;
}
li {
background-color: blue;
margin: 2px;
}
div {
background-color: brown;
}
section {
background-color: lightsteelblue;
}
nav ul {
list-style-type: none;
display: flex;
flex-direction: row;
}
<!----------------------------THE UPPPER PART------------------------------------------->
<div class="upperPart">
<!---------------------------HEADER-------------------------------------->
<header>
<h1>Untitled</h1>
<img src="" alt="logo" name="logo" />
<h3>description in form of a slogan</h3>
</header>
<!---------------------------NAVIGATION----------------------------------->
<nav>
<ul>
<li>Home</li>
<li>Shops and Products</li>
<li>Find Work/Worker</li>
<li>New Shops</li>
<li>Contact</li>
</ul>
</nav>
<!---------------------------SEARCH--------------------------------------->
<div>
<form method="post" action="searchAppPhp.php">
<label>Search </label>
<input type="text" id="search" size="50" />
<input type="submit" name="search"/>
</form>
</div>
</div>
<!----------------------------THE MIDDLE PART------------------------------------------->
<div class="middlePart">
<section>
<article>
</article>
</section>
</div>
<div class="downPart">
<footer>
</footer>
</div>
CSS Specificity.
Since you used .upperPart * to null styles instead of arguably-preferably using * {}.
And since we are not supposed to ever use !important (unless we really, really know what we're doing)...
you'll need to use a more specific Rule as override. I.e:
.upperPart header {
background-color: darkolivegreen;
}
Etc. for all your nulled .upperPart descendant Elements (*).
Suggestion:
Don't style TAGS directly (or keep it minimal, margins, font-size, paddings etc).
Style only Classes or IDs.
/* QuickReset */
* {
margin:0;
box-sizing: border-box;
padding: 0;
}
/* DEFAULT STYLES FOR TAGS */
h1,
h2,
h3 {
/* Keep it minimal */
}
nav {
/* Keep it minimal */
}
ul {
/* Keep it minimal */
list-style-type: none;
display: flex;
flex-direction: row;
}
li {
/* Keep it minimal */
}
/* STYLES FOR SPECIFIC CLASSES */
.upperPart {
background-color: darksalmon;
}
/* ...Etc... */
<div class="upperPart">
<header>
<h1>Untitled</h1>
<img src="" alt="logo" name="logo" />
<h3>description in form of a slogan</h3>
</header>
<nav>
<ul>
<li>Home</li>
<li>Shops and Products</li>
<li>Find Work/Worker</li>
<li>New Shops</li>
<li>Contact</li>
</ul>
</nav>
<div>
<form method="post" action="searchAppPhp.php">
<label>Search </label>
<input type="text" id="search" size="50" />
<input type="submit" name="search">
</form>
</div>
</div>
<div class="middlePart">
<section>
<article>
<p>ARTICLE HERE</p>
</article>
</section>
</div>
<div class="downPart">
<footer>
<p>FOOTER HERE</p>
</footer>
</div>
Need advice on html as i am not expert on this.
I need to display following form buttons on a navigation bar on top of a web page but they are coming on different lines. I want this to be responsive so for smaller screens they adjust on different lines but if enough area , should display on nav bar in a single line. Tried few css but was not able to get it right.
Suggestion....
<body class="body">
<header>
<nav>
<ul>
<li><form action="/create" ><button type="submit">Create</button></form></li>
<li><form action="/update" ><button type="submit">Update</button></form></li>
<li><form action="/delete" ><button type="submit">Delete</button></form></li>
</ul>
</nav>
</header>
<div>
</div>
</body>
You Add CSS like this
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: left;
}
li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
<body class="body">
<header>
<nav>
<ul>
<li><form action="/create" ><button type="submit">Create</button></form></li>
<li><form action="/update" ><button type="submit">Update</button></form></li>
<li><form action="/delete" ><button type="submit">Delete</button></form></li>
</ul>
</nav>
</header>
<div>
</div>
</body>
You can use:
li, form { display: inline; }
I am trying to build a site (just to learn, is not an actual website) and at the top there's links to different sections of the page. The HTML goes as follows:
<!DOCTYPE html>
<html>
<head>
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet">
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="nav">
<div class="container">
<ul>
<li>Airbnb logo</li>
<li>Browse</li>
</ul>
<ul>
<li>Sign Up</li>
<li>Log In</li>
<li>Help</li>
</ul>
</div>
</div>
<div class="header">
<div class="container">
<h1>Find a place to stay.</h1>
<p>Rent from people in over 34,000 cities and 192 countries.</p>
</div>
</div>
<div class="learn-more">
<div>
<div>
<div>
<h3>Travel</h3>
<p>From apartments and rooms to treehouses and boats: stay in unique spaces in 192 countries.</p>
<p>See how to travel on Airbnb</p>
</div>
<div>
<h3>Host</h3>
<p>Renting out your unused space could pay your bills or fund your next vacation.</p>
<p>Learn more about hosting</p>
</div>
<div>
<h3>Trust and Safety</h3>
<p>From Verified ID to our worldwide customer support team, we've got your back.</p>
<p>Learn about trust at Airbnb</p>
</div>
</div>
</div>
</div>
</body>
</html>
Now I am trying to style the page, but I want all the elements of the navbar in the same line.
So far I have:
.nav a {
color: #5a5a5a;
font-size: 11px;
font-weight: bold;
padding: 14px 10px;
text-transform: uppercase;
}
.nav li {
display: inline;
}
.header {
background-image:url('http://bit.ly/1KIFZoI');
background-size: cover;
height: 300px;
}
.header h1 {
color: #fff;
font-size: 48px;
font-family: 'Shift', sans-serif;
font-weight: bold;
}
.header p {
font-size: 20px;
color: #fff;
}
However, the display: inline; still leaves my navbar in two lines. I want them all in the same line if possible not putting all the elements in the same list (same ul)
Thanks!
Just do this:
ul{
display: inline-block;
vertical-align: middle;
}
Beware: you have default padding in the <ul>, because of that you
have a gap between them. Just add padding:0 and/or margin:0to the
<ul> to eliminate the gap ( adjust your needs ).
DEMO HERE
please view images below:
http://gyazo.com/c3ffe1d0a48b717f695d7cbd860eda50.png (Design view)
http://gyazo.com/a1e09aacc855c013d349017d0487402d.png (Live & browser view)
As you can see in the design view everything that has been placed on the page looks fine, and is also exactly what I want! But when I go to live view or preview in a web browser it shows differently, with some of the content overlapping my navigation. I really do not know what to do? I will display my code below:
HTML:
<nav>
<ul>
<li> Home</li>
<li> News</li>
<li> Events</li>
<li> Galleries</li>
<li> Video </li>
<li> History</li>
<li> Contact</li>
</ul>
</nav>
<div id="contactheader">
<p>Get in touch with FIFAScene: </p>
</div>
<p> </p>
<div id="contactcontent">
<p>If you have any feedback regarding our website, or wish to comment on anything FIFA eSport related, then please contact us via:</p>
</div>
<p> </p>
<p> </p>
<ul>
<div id="contacthotmail">
<li>FIFAScene#hotmail.com<img src="images/icons/outlook.png" width="112" height="95"></li>
</div>
<div id="contactsm">
<li>www.twitter.com/FIFAScene<img src="images/icons/twitter.png" width="94" height="78">
www.facebook.com/FIFAScene<img src="images/icons/facebook.png" width="67" height="63"></li>
</div>
</ul>
CSS:
nav {
float:left;
position:relative;
}
nav ul li {
display:block;
margin:20%;
padding:30%;
list-style-type: none;
font-family:Segoe UI Light;
font-size:30px;
text-align: center;
}
#contactheader {
text-align:center;
color:#0099FF;
font-family:Segoe UI Light, sans-serif;
font-size:20px;
}
#contactcontent {
text-align:center;
color:#0099FF;
font-family:Segoe UI Light, sans-serif;
font-size:18px;
}
#contacthotmail {
text-align:center;
color:#0099FF;
font-family:Segoe UI Light, sans-serif;
font-size:18px;
}
#contactsm {
text-align:center;
color:#0099FF;
font-family:Segoe UI Light, sans-serif;
font-size:18px;
margin-top:40px;
}
Sorry if I have provided too much information, I am relatively new to designing websites and programming!
Thank you.
Probably your version of DW doesn't see some of the HTML5 elements as a block type element. As a concession to the program you could add a line to the nav element in your css:
display: block;
Thereby embettering the 'prognosis' of the design view as you type.
Edit starts here:
Myself I use the Design-View to type content. It can be handy for some UTF characters, like the double quotes for instance. I use it a lot when writing (un-)ordered lists. Sometimes I use it to type content without the visual aids or css enabled. My advise is to use it as a tool but to have a browser open at the same time, with your document loaded. Adobe provided several tutorials that offered strategies for almost have a consistent preview of the page in design-view, but that's almost. Live view offers a better standard.
Because of a comment, I tried the code in DW5.5. I wanted to see how far I would get keeping the nav and main tag and have these as floats.
To have some consistency in preview of the design-view and Live-View (hitting ALT+11 on windows) a wrapper that would clear the float (see the link to an article of Louis Lazaris) seemed to help.
I tried the the pyramid layout of the contact logo's as floats, but I could not center the two links below properly without too much hustle. To have these centered as well I made these display as inline-blocks.
Further the padding on the navigation list-items were a bit exotic having 50% on both sides.
html,
body {
width: 100%;
}
body {
font: 18px/1.25 "Segoe UI Light";
color: #0099FF;
}
html, body,
h1, h2, h3, p, ul, li,
div,
nav, main,
a, img,
a img {
margin: 0;
border: none;
padding: 0;
}
h1 {
font-size: 2.618em;
text-align: center;
padding: 1em 0;
margin-left: 20%;
margin-right: 5%;
}
a {
color: #0099FF;
text-decoration: none;
}
.wrap {
width: 100%;
overflow: hidden;
}
nav, main {
float: left;
text-align: center;
}
nav {
overflow: hidden;
position: relative;
width: 20%;
}
main {
width: 75%;
text-align: center;
}
ul {
list-style-type: none;
}
nav ul {
}
nav ul li {
font-size: 1.666em;
}
nav ul li a {
display: block;
line-height: 2.25;
}
.contactheader {
font-size: 1.666em;
}
.contactcontent {
font-size: 1em;
}
.contactsms {
display: inline-block;
margin: auto;
}
.contactsms ul {
}
.contactsms ul li {
display: inline-block;
padding: 1em 1em;
margin: 0 auto;
}
.contactsms ul li img {
white-space: nowrap;
vertical-align: text-bottom;
}
.whiteSpace {
height: 2em;
}
<div class="wrap">
<h1>Contact Us</h1>
<nav>
<ul>
<li>Home</li><!--
--><li>Design</li><!--
--><li>View</li><!--
--><li>Mess</li><!--
--><li>Video </li><!--
--><li>History</li><!--
--><li>Contact</li>
</ul>
</nav>
<main>
<div class="contactheader"><p>Get in touch with DreamWeaver:</p></div><!-- contactheader -->
<div class="whiteSpace"></div><!-- whiteSpace -->
<div class="contactcontent">
<p>If you're interested in how the design view could be of help in your <em>'workflow'</em>, its abilities and disabilities, look out for AdobeTV tutorials like:</p>
</div><!-- contactcontent -->
<div class="whiteSpace"></div><!-- whiteSpace -->
<div class="whiteSpace"></div><!-- whiteSpace -->
<ul>
<li class="contacthotmail">Taming the Web, Greg Rewis<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Adobe_Systems_logo_and_wordmark.svg/200px-Adobe_Systems_logo_and_wordmark.svg.png" width="112" height="95"></li><!--
--><li class="whiteSpace"></li><!--
--><li class="whiteSpace"></li><!--
--><li class="contactsms">
<ul>
<li>StackOverflow: center floats?<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Stack_Overflow_logo.svg/200px-Stack_Overflow_logo.svg.png" width="94" height="78"></li><!--
--><li>clearing-floats/louis-lazaris<img src="https://upload.wikimedia.org/wikipedia/en/c/c0/Smashing_Magazine_logo.png" width="67" height="63"></li>
</ul>
</li>
</ul>
</main>
</div>
If you want to use Dreamweaver you should ditch the design view and get in the habit of previewing everything in the browser and troubleshooting with the browsers web inspector.
If you really want to see a live preview of your css and positioning, you can do some of that in the web inspector. If you have access to a Mac you should consider looking at Espresso <Link> by the folks at macrabbit.
Also, beware of the non breaking space returns (<p> </p>) tags that Dreamweaver is making, delete em and use css instead.