hey so im doing something for a Webdesign class I'm taking. I'm trying to select these <h2>'s inside element <divclass=left> but It's not working for me.
nav {
display: flex;
flex-direction: row;
height: 75px;
background-color: rebeccapurple;
color: white;
justify-content: space-between;
}
.left h2{margin-left: 20px}
.right{
}
body{padding:0; margin: 0}
.boxs {
display: flex
}
.boxs>* {
padding: 5px;
height: 200px;
border: black solid 2px;
box-sizing: border
}
<nav>
<nav>
<div class=left></div> <i class="fas fa-ad"></i>
<h2>Home</h2>
<h2>Browser</h2>
<h2>Download</h2>
<h2>Contact us</h2>
</nav>
<div class="right"><h2>Sign-in</h2></div>
</nav>
Your div with the class left is not wrapping anything. Your HTML should look like this if you want the CSS .left h2 to work.
.left h2{margin-left: 20px}
<nav>
<nav>
<div class="left"> <i class="fas fa-ad"></i>
<h2>Home</h2>
<h2>Browser</h2>
<h2>Download</h2>
<h2>Contact us</h2>
</div>
</nav>
<div class="right">
<h2>Sign-in</h2>
</div>
</nav>
You can try this if you want to select h2 elements:
nav h2 {
color: red;
}
Related
i am developing my portfolio website but i came into an error can anyone just help me.
i need to make my social icons responsive.
Here The The Image For Desktop Version.
I need To make it responsive and direction to row for mobile version. Please Help Me.
As You Can See Here The Social Icons Are Not Responsive.
index.html
```
<!-- home -->
<section class="home bd-grid" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1">Hello, Myself</div>
<div class="text-2">Piyush Shrivastava</div>
<div class="text-3">And I'm a <span class="typing"></span></div>
Download CV
</div>
</div>
<div class="social">
<ul>
<li>
<div class="circle">
<i class="fa fa-facebook-f" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-instagram" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-twitter" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-youtube" aria-hidden="true"></i>
</div>
</li>
</ul>
</div>
</section>```
Styles.css
.home{
display: flex;
flex-wrap: wrap;
background: url("/img/banner.jpg") no-repeat center;
height: 100vh;
color: #fff;
min-height: 500px;
background-size: cover;
background-attachment: fixed;
font-family: 'Ubuntu', sans-serif;
}
.home .max-width{
width: 100%;
display: flex;
}
.home .max-width .row{
margin-right: 0;
}
.home .home-content .text-1{
font-size: 27px;
}
.home .home-content .text-2{
font-size: 75px;
font-weight: 600;
margin-left: -3px;
}
.home .home-content .text-3{
font-size: 40px;
margin: 5px 0;
}
.home .home-content .text-3 span{
color: #32de84;
font-weight: 500;
}
.home .home-content a{
display: inline-block;
background: #32de84;
color: #fff;
font-size: 25px;
padding: 12px 36px;
margin-top: 20px;
font-weight: 400;
border-radius: 6px;
border: 2px solid #32de84;
transition: all 0.3s ease;
}
.home .home-content a:hover{
color: #32de84;
background: none;
}
.social{
position: absolute;
top: 35%;
right: 5%;
color: #fff;
/* background-color: #ffffff; */
}
.social ul{
list-style: none;
}
.social li{
margin-bottom: 20px;
text-align: center;
}
.circle{
background-color: transparent;
border: 2px solid white;
border-radius: 200px;
height: 35px;
width: 35px;
}
.social i{
padding-top: 7px;
height: 30px;
width: 30px;
color: #ffffff;
}
#media (max-width: 947px) {
.home .home-content .text-2 {
font-size: 60px;
}
}```
Try thinking of your problem the other way around.
Layout shifts like this are much easier to deal with when working with a 'mobile first' approach. (style the mobile version and then override at a min-width media query to style the desktop version, rather than styling the desktop perfectly and then trying to fold everything down to mobile.)
I've knocked up a quick demo of what should work for you.
This is NOT a direct replication of or fix of your existing code, just a demo of the methods you could use, but hopefully from this demo and the snippets, you should understand what is happening and be able to apply some of these methods to your own code.
The method is entirely done with flex properties.
The socials are no longer absolutely positioned and the unnecessary social wrapper div is removed.
I've added border colors and padding just to more obviously show you whats happening to the box model when you resize your browser.
To view the demo, click 'run code snippet' - but make sure to then also click the 'full page' option otherwise it'd only show you the mobile layout.
Here's the JSFiddle where I created the demo incase it's useful: CLICK TO VIEW FIDDLE
.contentWrapper {
border: 1px solid pink;
padding: 10px;
}
.mainContent {
border: 1px solid blue;
padding: 10px;
}
.social {
border: 1px solid green;
padding: 10px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: row;
gap: 10px;
}
.circle {
background-color: red;
border: 2px solid white;
border-radius: 200px;
height: 35px;
width: 35px;
}
#media screen and (min-width: 948px) {
.myWrapper {
display: flex;
min-height: 100vh;
flex-direction: row;
}
.contentWrapper {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center
}
.mainContent {
width: calc(100% - 55px);
max-width: 1000px;
margin: 0 auto;
}
.social {
display: flex;
flex-direction: column;
justify-content: center;
}
.social ul {
display: flex;
flex: 0 0 55px;
flex-direction: column;
}
}
<section class="myWrapper">
<div class="contentWrapper">
<div class="mainContent">
<div class="text-1">Hello, Myself</div>
<div class="text-2">Piyush Shrivastava</div>
<div class="text-3">And I'm a <span class="typing"></span></div>
Download CV
</div>
</div>
<ul class="social">
<li>
<div class="circle">
<i class="fa fa-facebook-f" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-instagram" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-twitter" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-youtube" aria-hidden="true"></i>
</div>
</li>
</ul>
</section>
To make icons in row
we can do it using #media in the approach
APPROACH
Use flexbox to make your icons in a row
and use grid to make everything in a row when you are on a big screen
you can also set width and then add margin auto to make things centre but using justify-content center is better ---> not told in this answer
<!-- home -->
<section class="home bd-grid" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1">Hello, Myself</div>
<div class="text-2">Piyush Shrivastava</div>
<div class="text-3">And I'm a <span class="typing"></span></div>
Download CV
</div>
</div>
<div class="social">
<ul class="icons"> // give class icons to make it a flexbox
<li>
<div class="circle">
<i class="fa fa-facebook-f" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-instagram" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-twitter" aria-hidden="true"></i>
</div>
</li>
<li>
<div class="circle">
<i class="fa fa-youtube" aria-hidden="true"></i>
</div>
</li>
</ul>
</div>
</section>```
***css***
.icons{
display: flex;
flex-direction: column;
justify-content: center;
}
#media screen and (min-width: 800px //your mobile screen width) {
.icons {
display: flex;
justify-content:center;
}
.home{
display:grid;
width: 100vw;
gap: 20px;
text-align:center;
grid-template-column:2fr 2fr;
}
I need help with my grid layout for a free code camp project.
Basically, I'd like to show 3 of my portfolio pages in a row. I setup a grid layout for this and can't seem to get the middle page to lineup with the others. Also, as I am brand new, feel free to give feedback on what I have so far in general.
here is the link to the codepen just in case https://codepen.io/eddiepearson/pen/xMaaYX
* {
#import url('https://fonts.googleapis.com/css?family=Roboto+Mono:300,300i,400');
}
html, body {
margin: 0;
padding: 0;
}
nav ul {
text-align: right;
position: fixed;
margin-top: 0;
width: 100%;
background-color: #002171;
}
nav ul li {
display: inline-block;
margin: 55px;
margin-bottom: 15px;
margin-top: 30px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
#media only screen and (max-width: 500px) {
nav ul {
text-align: left;
height: 75px;
}
nav ul li {
margin: 20px;
height: 5px;
}
}
.intro {
top: 0;
background: #002171;
min-height: 55vh;
padding-top: 45vh;
}
.intro p {
text-align: center;
color: #fff;
}
.intro h1 {
text-align: center;
color: #fff;
}
.work {
margin-top: 50px;
}
.work-header {
text-align: center;
}
#projects {
display: grid;
grid-template-columns: 300px 300px 300px;
grid-row-columns: 300px 300px;
justify-content: space-evenly;
}
#third-p {
}
.project-pic {
width: 100%;
}
.project-title {
text-align: center;
}
<nav>
<ul style="list-style-type: none" id="navbar">
<li>About</li>
<li>Work</li>
<li>Contact</li>
</ul>
</nav>
<section>
<div id="welcome-section" class="intro">
<h1>Hey i'am eddie</h1>
<p>a web dev with a focus on UX</p>
</div>
</section>
<section>
<h2 class="work-header">These are some of my projects.</h2>
<div id="projects" class="work">
<div id="first-p">
<a href="https://codepen.io/eddiepearson/pen/vbxQEp" target="_blank" class="project project-box">
<img class="project-pic" src="https://previews.dropbox.com/p/thumb/AAU0aRvU53Ban4nVNY5N70nno6nDVvhkDsD0qSzP0NYsVh20CPfm-jFQB4GrArV09A9eVa8YUpJqpQJDdBaHnyJ24GAfLey4u1qdJZ5gp2JY4WF-DkfnXfIawSA8n7jronkkUR_mT9xH5sFDTm0jagwpWpM93tn_zZs8c62-3c9fAQKvFmvjqyOjFenQsBgK5XUG62avpwvwjGtSf0IWMiXUrXUWhJIl2wFc3L4UK4z-Hw/p.png?size_mode=5" alt="project-pic">
<div class="project-title">
Tribute Page
</div>
</div>
</a>
<div id="second-p">
<a href="https://codepen.io/eddiepearson/pen/vbxQEp" target="_blank" class="project project-box">
<img class="project-pic" src="https://previews.dropbox.com/p/thumb/AAU0aRvU53Ban4nVNY5N70nno6nDVvhkDsD0qSzP0NYsVh20CPfm-jFQB4GrArV09A9eVa8YUpJqpQJDdBaHnyJ24GAfLey4u1qdJZ5gp2JY4WF-DkfnXfIawSA8n7jronkkUR_mT9xH5sFDTm0jagwpWpM93tn_zZs8c62-3c9fAQKvFmvjqyOjFenQsBgK5XUG62avpwvwjGtSf0IWMiXUrXUWhJIl2wFc3L4UK4z-Hw/p.png?size_mode=5" alt="project-pic">
<div class="project-title">
Tribute Page
</div>
</div>
</a>
<div id="third-p">
<a href="https://codepen.io/eddiepearson/pen/vbxQEp" target="_blank" class="project project-box">
<img class="project-pic" src="https://previews.dropbox.com/p/thumb/AAU0aRvU53Ban4nVNY5N70nno6nDVvhkDsD0qSzP0NYsVh20CPfm-jFQB4GrArV09A9eVa8YUpJqpQJDdBaHnyJ24GAfLey4u1qdJZ5gp2JY4WF-DkfnXfIawSA8n7jronkkUR_mT9xH5sFDTm0jagwpWpM93tn_zZs8c62-3c9fAQKvFmvjqyOjFenQsBgK5XUG62avpwvwjGtSf0IWMiXUrXUWhJIl2wFc3L4UK4z-Hw/p.png?size_mode=5" alt="project-pic">
<div class="project-title">
Tribute Page
</div>
</div>
</a>
</div>
</section>
First, you have a small issue (typo I assume) here in the CSS
grid-template-columns: 300px 300px 300px;
grid-row-columns: 300px 300px;
Shouldn't that last part be grid-template-rows?
Also you could use this to manually control each element in the grid:
#first-p {
grid-row:1;
grid-column:3;
}
I'm trying to align some items to the left, but I don't know what I'm doing wrong.
I'm making the youtube header, and at this time, I've done this
I got to align the first two items to the right with a simple padding, but when it comes to the left side of the header, nothing works. I've used align-items but they do not move.
this is my html code:
header {
width: 100%;
padding: 0px;
/*FLEX*/
display: flex;
flex-direction: row;
border-bottom: 1px solid #000;
}
header .youtube nav a span {
color: red;
padding: 5px;
line-height: 50px;
}
header .menu nav a span {
padding: 30px;
line-height: 50px;
}
header .bloque nav a span {
line-height: 50px;
align-items: flex-end;
}
header .bloque nav img {
line-height: 50px;
align-items: flex-end;
width: 50;
}
<header>
<div class="menu">
<nav>
<span class="icon-menu"></span>
</nav>
</div>
<div class="youtube">
<nav>
<span class="icon-youtube"></span>YouTube
</nav>
</div>
<form>
<fieldset>
<input type="search" placeholder="Search">
<button type="submit">
<span class="icon-magnifying-glass"></span>
</button>
</fieldset>
</form>
<div class="bloque">
<nav>
<span class="icon-camera"></span>
<span class="icon-grid"></span>
<span class="icon-forward"></span>
<span class="icon-globe"></span>
<img src="guía.png" width="100">
</nav>
<div/>
</header>
when I use justify-content:Space-round, the items are placed the way I want to, but not properly spaced between them. But for some strange reason when I use align-item:flex-end they are arranged like in the pic related. how do I solve this? any advice?
To align items within the header tag you need to add justify-content: flex-end; to the header to read more about it Check this site
header {
width: 100%;
padding: 0px;
/*FLEX*/
display: flex;
flex-direction: row;
justify-content: flex-end;
/* justify-content: flex-end;*/ /*uncomment to align left*/
align-items: center; /* to vertical align items */
border-bottom: 1px solid #000;
}
header .youtube nav a span {
color: red;
padding: 5px;
line-height: 50px;
}
/* header .menu nav a span {
padding: 30px;
line-height: 50px;
} */
header .bloque nav a span {
line-height: 50px;
align-items: flex-end;
}
header .bloque nav img {
line-height: 50px;
align-items: flex-end;
width: 50;
}
<header>
<div class="menu">
<nav>
<span class="icon-menu"></span>
</nav>
</div>
<div class="youtube">
<nav>
<span class="icon-youtube"></span>YouTube
</nav>
</div>
<form>
<fieldset>
<input type="search" placeholder="Search">
<button type="submit">
<span class="icon-magnifying-glass"></span>
</button>
</fieldset>
</form>
<div class="bloque">
<nav>
<span class="icon-camera"></span>
<span class="icon-grid"></span>
<span class="icon-forward"></span>
<span class="icon-globe"></span>
<img src="guía.png" width="100">
</nav>
<div/>
</header>
I have a simple list item that I want to format. It contains 3 DIV's. I want the first DIV to be left justified, the second DIV to be able to grow as needed, and the third DIV to be right justified. I have the three DIV's stacked side by side, but I can't figure out how to get the last DIV to right justify. This is what it looks like now:
<li *ngFor="let script of scripts" [class.selected]="script === selectedScript" (click)="onSelect(script)">
<div class="container">
<div class="left">
<span class="badge">{{script.scriptOrderID}}</span>
</div>
<div class="center">
<span>{{script.scriptName}}</span>
</div>
<div class="right">
<span class="badge2">{{script.scriptID}}</span>
</div>
</div>
</li>
This is what I want it to look like:
.container {
display: flex;
}
.left {
width: 70px;
}
.center{
display: flex;
}
.right{
}
Take a look at flexbox, easy to use, and with flex-end it'll be fast to get your blocks at the end.
<div class="line">
<div class="first_block">
</div>
<div class="text">
Hello
</div>
<div class="second_block">
</div>
</div>
.line {
height : 40px;
width : 100%;
display : flex;
flex-flow : row wrap;
background-color : gray;
}
.first_block, .second_block {
background-color : blue;
width : 40px;
}
.text {
flex-grow : 1;
}
JSFIDDLE to show you the result.
Cheers !
You can do it without all the divs in the li...
Display your list-item as table, and the span's inside it as table-cell:
* { margin: 0; padding: 0; list-style: none; box-sizing: border-box; }
ul {
width: 100%;
}
li {
width: 100%;
display: table;
margin-bottom: 2px;
}
li > span {
display: table-cell;
background: lightgrey;
}
li > span:first-child,
li > span:last-child {
background: black;
color: white;
width: 3em;
}
<ul>
<li>
<span>60</span>
<span>Click Add a Printer</span>
<span>53</span>
</li>
<li>
<span>70</span>
<span>Click "The printer I want isn't listed"</span>
<span>54</span>
</li>
<li>
<span>80</span>
<span>Select "Add a printer using a TCP/IP address or hostname" Click Next</span>
<span>55</span>
</li>
</ul>
Flexbox alternativ
* { margin: 0; padding: 0; list-style: none; box-sizing: border-box; }
ul {
width: 100%;
}
li {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin-bottom: 2px;
}
li > span {
background: lightgrey;
flex-grow: 1;
}
li > span:first-child,
li > span:last-child {
background: black;
color: white;
width: 3em;
flex-grow: 0;
}
<ul>
<li>
<span>60</span>
<span>Click Add a Printer</span>
<span>53</span>
</li>
<li>
<span>70</span>
<span>Click "The printer I want isn't listed"</span>
<span>54</span>
</li>
<li>
<span>80</span>
<span>Select "Add a printer using a TCP/IP address or hostname" Click Next</span>
<span>55</span>
</li>
</ul>
You can use a code like below.
You have fixed width divs on both sides and a center div with fluid width.
That should do the trick.
.container > div {
float: left;
padding: 0 10px;
}
.left{
width: 30px;
}
.right {
width: 30px;
}
.center {
width: calc( 100% - 120px);
background: #ccc;
}
<div class="container">
<div class="left">
<span class="badge">23</span>
</div>
<div class="center">
<span>test</span>
</div>
<div class="right">
<span class="badge2">44</span>
</div>
</div>
Using flexbox you can do this:
.container {
line-height: 50px;
background: #e1e1e1;
display: flex;
justify-content: space-between;
}
.center {
flex: 1;
}
.badge,
.badge2 {
display: block;
background: purple;
color: white;
text-align: center;
padding: 0 15px;
}
<div class="container">
<div class="left">
<span class="badge">*</span>
</div>
<div class="center">
<span>The Name will grow</span>
</div>
<div class="right">
<span class="badge2">**</span>
</div>
</div>
I'm having this issue with my footer. I am trying to put the logo image in top center part of the footer and the text part has somehow went underneath the footer. How can I make it push up in the footer section? I have an image below so you guys have a better understanding:
HTML:
<div class="footer text-center spacer">
<div class="col-sm-4">
<span>Phone Numbers:</span>
<p>077***** <span>or </span>077*****</p>
</div>
<div class="col-sm-4">
<p> <img src= "images/preloaderlogo2%20.png" class = "swiftly"/></p>
<p class="wowload flipInX"><i class="fa fa-facebook fa-2x"></i> <i class="fa fa-instagram fa-2x"></i> <i class="fa fa-twitter fa-2x"></i> </p>
Copyright 2016 Swift Digi. All rights reserved.
</div>
<div class="col-sm-4">
<span>Email:</span>
<p>#hotmail.com</p>
</div>
CSS:
/*===FOOTER===*/
.footer {
background-color:#0A0A0A;
color: #fff;
font-size: 1em;
color: #aaa;
}
.footer a {
color: #aaa;
margin: 0 1em;
}
#media (max-width: 767px) {
.footer {
margin-top: 2em;
padding-bottom: 2em;
}
}
.footer p{
color: green;
font-weight: 700;
font-family: 'Roboto', sans-serif;
}
.footer span{
color:white;
font-weight: 400;
}
.footer .col-sm-4{
margin-bottom: 20px;
}
.footer img{
text-align:center;
height:40px;
}
So, How can I push the logo image a bit higher and make the text be in the footer and not underneath the footer?
html, body {
height: 100%;
}
#container {
min-height: 100%;
margin-bottom: -330px;
position: relative;
}
#footer {
height: 330px;
position: relative;
}
<div id="container">
<div id="header">Header</div>
<div id="nav">
<ul>
<li>Home</li>
<li>Page 1</li>
<li>Page 2</li>
</ul>
</div>
<div id="content">Content Here.</div>
<div class="clearfooter"></div>
</div><!—End Container—>
<div id="footer">Footer Here.</div>
Check this link:-http://fortysevenmedia.com/blog/archives/making_your_footer_stay_put_with_css
use position:relative and then use top or bottom according to adjustment
check the documentation link to discription