I'm trying to figure out why my right sidebar only goes half-way up the screen and what I'm doing wrong.
I have the HTML and CSS at the bottom and a picture of the website at the bottom. I'm trying to get the text in the middle but when I do that the text blocks the right sidebar from going all the way up. I have a picture of what it's supposed to look like at the bottom also. I could really use some help with this.
/* right sidebar */
#right_sidenav {
width: 180px;
float: right;
background-color: #F5DEB3
padding: 0;
}
/* the styles for the section */
html {
background-image:url(../images/bats.gif);
background-repeat: repeat;
}
body {
font-family: Arial, Helvetica, sans-serif;
width: 800px;
background-color: white;
border: 5px solid black;
box-shadow: 5px 5px 5px 5px black;
margin: 0 auto;
}
section {
width: 600px;
float: right;
padding-right: 20px;
padding-left: 20px;
padding-bottom; 20px;
}
main {
clear: both;
}
aside {
width: 160px;
float: left;
}
section h2 {
margin-left: 0;
}
section figcaption {
float: right;
clear: right;
margin-left: 10em;
padding-right: 15em;
}
section img {
float: left;
margin: 0;
padding: 0;
}
<section>
<h2>20" Deranged Cat</h2>
<figure>
<picture>
<img src="images/cat1.jpg" alt="cat">
</picture>
<figcaption>This cat provides its own light and is perfect for a
backyard haunting.
Price 19.99</figcaption>
</figure>
</section>
<div id="right_sidenav">
<h5>Customers who bought this product also bought:</h5>
<ul>
<li>
<figure>
<picture>
<img src="images/flying_bats.jpg" alt="flying bat">
</picture>
<figcaption>
Flying bats
</figcaption>
</figure>
</li>
<li>
<figure>
<picture>
<img src="images/rat1.jpg" alt="rat">
</picture>
<figcaption>
16" Ugly rat
</figcaption>
</figure>
</li>
<li>
<figure>
<picture>
<img src="images/strobe1.jpg" alt="strobe light">
</picture>
<figcaption>
Mini strobe light
</figcaption>
</figure>
</li>
</ul>
</div>
'#' usually stops a sidebar when you go to it. Only classes will work with this.
You also need to define everything. Style is not defined. No content is the <style> tags are defined either.
When you have a tag in html and want to define it with CSS then you do not put a '.' in front of the class as it is a tag not a class
<section>
<h2>20" Deranged Cat</h2>
<figure>
<picture>
<img src="images/cat1.jpg" alt="cat">
</picture>
<figcaption>This cat provides its own light and is perfect for a
backyard haunting.
Price 19.99</figcaption>
</figure>
</section>
<div id="right_sidenav">
<h5>Customers who bought this product also bought:</h5>
<ul>
<li>
<figure>
<picture>
<img src="flying_bats.jpg" alt="flying bat">
</picture>
<figcaption>
Flying bats
</figcaption>
</figure>
</li>
<li>
<figure>
<picture>
<img src="images/rat1.jpg" alt="rat">
</picture>
<figcaption>
16" Ugly rat
</figcaption>
</figure>
</li>
<li>
<figure>
<picture>
<img src="images/strobe1.jpg" alt="strobe light">
</picture>
<figcaption>
Mini strobe light
</figcaption>
</figure>
</li>
</ul>
</div>
/* right sidebar */
#right_sidenav {
width: 180px;
float: right;
background-color: #F5DEB3
padding: 0;
/* the styles for the section */
html {
background-image:url(../images/bats.gif);
background-repeat: repeat;
}
li {
list-style: none;
}
body {
font-family: Arial, Helvetica, sans-serif;
width: 800px;
background-color: white;
border: 5px solid black;
box-shadow: 5px 5px 5px 5px black;
margin: 0 auto;
}
section {
width: 600px;
float: right;
padding-right: 20px;
padding-left: 20px;
padding-bottom; 20px;
}
.main {
clear: both;
}
.aside {
width: 160px;
float: left;
}
.section h2 {
margin-left: 0;
}
.section figcaption {
float: right;
clear: right;
margin-left: 10em;
padding-right: 15em;
}
.section img {
float: left;
margin: 0;
padding: 0;
}
Related
I'm new and I cant align my social redirect images to be centered to the "contact me" header. Text align doesn't work and other solutions I found for my problems just puts it in order vertically.
<link rel="stylesheet" href="styles.css">
<style>
.feature {
display: inline-block;
margin: 0px;
padding: 0px;
text-align: center;
}
.feature figure {
display: inline-block;
position: relative;
}
.resize {
text-decoration: none;
width: 128px;
height: 128px;
display: inline-block;
}
</style>
</head>
<body>
[HEADER]
<h1>Contact Me!</h1>
<section class="feature">
<figure>
<a href="url">
<img class="resize" src="images/discord.png" alt="Discord"></a>
<figcaption></figcaption>
</figure>
<figure>
<a href="url">
<img class="resize" src="images/insta.png" alt="Instagram"></a>
<figcaption></figcaption>
</figure>
</section>
</body>
</html>
Play around with the margins in .feature figure. I changed the size of the images and added a border to them so i could see what was going on.
.feature {
display: inline-block;
margin: 0px;
padding: 0px;
text-align: center;
}
.feature figure {
border: 1px solid #ccc;
display: inline-block;
margin: 0 8px;
}
.resize {
text-decoration: none;
width: 64px;
height: 64px;
display: inline-block;
}
[HEADER]
<h1>Contact Me!</h1>
<section class="feature">
<figure>
<a href="url">
<img class="resize" src="images/discord.png" alt="Discord"></a>
<figcaption></figcaption>
</figure>
<figure>
<a href="url">
<img class="resize" src="images/insta.png" alt="Instagram"></a>
<figcaption></figcaption>
</figure>
</section>
I'm trying to make the images on this page have a rounded edge and I've applied the appropriate CSS styling using combinator selectors. But somehow they are not getting applied? Same for the captions.
.pagecontents{
display: flex;
flex-wrap: wrap;
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
border-radius: 10px;
height: 500px;
width: 1200px;
background-color: #A4B3B6
}
.pagecontents figure img{
border-radius: 8px;
padding: 40px 10px 20px 10px
}
.pagecontents figure figcaption{
font-family: Arial
text-align: right;
font-size: 16px;
font-weight: bold;
}
<div class="pagecontents">
<figure>
<img src="https://images-na.ssl-images-amazon.com/images/I/91bbRIClz+L.jpg" alt="Cover of Norwegian Wood" height="300">
<figcaption>
Norwegian Wood <br>
Author: Haruki Murakami
</figcaption>
</figure>
<figure>
<img src="https://images-na.ssl-images-amazon.com/images/I/81XSN3hA5gL.jpg" alt="Cover of Hitchhiker's Guide to the Galaxy" height="300">
<figcaption>
Hitchhiker's Guide to the Galaxy <br>
Author: Douglas Adams
</figcaption>
</figure>
</div>
You've missed semicolon in CSS after font-family: Arial
border-radius is not visible because of padding - look here to see it.
(I've added background-color to <img>)
Probably, padding is not the best choice for <img>. Maybe, you should use margin?
.pagecontents{
display: flex;
flex-wrap: wrap;
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
border-radius: 10px;
height: 500px;
width: 1200px;
background-color: #A4B3B6
}
.pagecontents figure img{
border-radius: 8px;
margin: 40px 10px 20px 10px; /* Changed padding to margin, added semicolon */
}
.pagecontents figure figcaption{
font-family: Arial; /* Added semicolon */
text-align: right;
font-size: 16px;
font-weight: bold;
}
<div class="pagecontents">
<figure>
<img src="https://images-na.ssl-images-amazon.com/images/I/91bbRIClz+L.jpg" alt="Cover of Norwegian Wood" height="300">
<figcaption>
Norwegian Wood <br>
Author: Haruki Murakami
</figcaption>
</figure>
<figure>
<img src="https://images-na.ssl-images-amazon.com/images/I/81XSN3hA5gL.jpg" alt="Cover of Hitchhiker's Guide to the Galaxy" height="300">
<figcaption>
Hitchhiker's Guide to the Galaxy <br>
Author: Douglas Adams
</figcaption>
</figure>
</div>
.pagecontents figure img {
border-radius: 8px;
padding: 1em;
}
Add some paddings for .pagecontents figure figcaption{}
I am trying to make website but problem is that when i position header fix top 2 images figcatipion hide. I am trying to make website but problem is that when i position header fix top 2 images figcatipion hide.
/*********************
General
*********************/
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
}
a {
text-decoration: none;
}
h1, h3 {
margin: 0;
}
/*********************
Header
*********************/
.main-header {
background-color: #3cb371;
width: 100%;
float: left;
text-align: center;
position: fixed;
z-index: 1000;
}
.logo {
font-family: 'Indie Flower', cursive;
}
.name {
padding-top: 5px;
}
.occptn {
padding-bottom: 15px;
font-size: 15px;
}
.main-header a {
color: #fff;
margin: 0;
}
.main-nav {
background-color:#2e8b57;
font-weight: bold;
}
.main-nav a {
text-align: center;
}
.main-nav li {
display: inline-block;
padding: 15px;
}
.selected a:visited {
color: #000;
}
.main-nav a:hover {
color: #000;
}
/*********************
Images
*********************/
.container figure {
margin: 0;
float: left;
width: 45%;
padding: 0 20px ;
}
.container img {
max-width: 100%;
display: block;
}
.container figcaption {
clear: right;
background-color: #dcdcdc;
padding: 10px 0;
font-size: .8em;
}
.figureOne ,
.figureTwo {
}
.clearfix::after {
content: “”;
display: table;
clear: both;
}
/*********************
Footer
*********************/
.main-footer {
text-align: center;
width: 100%;
background-color: #7fffd4;
clear: left;
padding: 20px;
}
.main-footer a {
}
/*********************
Responsive Layout
*********************/
#media (min-width:660px) {
.main-header {
padding: 10px 0;
box-shadow: 0 5px #2e8b57;
}
.logo {
float: left;
width: 45%;
text-align: left;
padding-left: 20px;
}
.main-nav {
background-color: #3cb371;
float: right;
width: 45%;
}
.main-nav li {
padding-left: 10px ;
}
.occptn {
padding: 0;
}
}
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Irfan Hussain | Web Developer</title>
<link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet">
<link rel="stylesheet" href="normalize.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- Start Header -->
<header class="main-header">
<a class="logo" href="index.html">
<h1 class="name"> Irfan Hussain </h1>
<h3 class="occptn"> Web Developer </h3>
</a>
<ul class="main-nav">
<li class="selected">Portfolio</li>
<li>About</li>
<li>Contact</li>
</ul>
</header>
<!-- End Header -->
<div class="container clearfix">
<figure class="figureOne">
<figcaption> Experimentation with color and texture. </figcaption>
<img src="img/numbers-01.jpg" alt="Irfan Web Developer" />
</figure>
<figure class="figureTwo">
<figcaption> Playing with blending mode in photoshop. </figcaption>
<img src="img/numbers-02.jpg" alt="Irfan Web Developer" />
</figure>
<figure>
<figcaption> Trying to create 80's style glow. </figcaption>
<img src="img/numbers-06.jpg" alt="Irfan Web Developer" />
</figure>
<figure>
<figcaption> Drips created using Photoshop brushes </figcaption>
<img src="img/numbers-09.jpg" alt="Irfan Web Developer" />
</figure>
<figure>
<figcaption> Creating shapes using repetition. </figcaption>
<img src="img/numbers-12.jpg" alt="Irfan Web Developer" />
</figure>
</div>
<footer class="main-footer">
<p> ©2018 Copy right Irfan Hussain | Web Developer </p>
<img src="img/facebook-wrap.png" alt="Facebook" />
<img src="img/twitter-wrap.png" alt="Twitter" />
</footer>
</body>
</html>
I am trying to make website but problem is that when i position header fix top 2 images figcatipion hide.
I cant get these figures to centered. They're inside a section, I've tried so many variations. All is as it should be, they float in the right way. But no matter what I try with the sections or figure codes, they still do not center within the sections.
section {
width: 100%;
padding: 1rem;
display: table;
margin: 0 auto;
max-width: none;
background-color: #373B44;
height: 100vh;
}
section:nth-of-type(2n) {
background-color: white;
}
figure.snip1165 {
float: left;
margin: 1rem;
overflow: hidden;
min-width: 150px;
max-width: 300px;
background: #000000;
color: #333;
text-align: left;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
<section>
<figure class="snip1165">
<img src="http://test.nationalparkpaws.com/images/camping%20in%20mountains%20with%20ten.jpg" />
<figcaption>
<h3>Useful Tips</h3>
<p>
Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.
</p>
</figcaption>
</figure>
<figure class="snip1165 red">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample63.jpg" alt="sample63" />
<figcaption>
<h3>Caspian<span> Bellevedere</span></h3>
<p>
I don't need to compromise on my principles, because they don't have the slightest bearing on what happens to me anyway.
</p>
</figcaption>
</figure>
<figure class="snip1165 orange">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample64.jpg" alt="sample64" />
<figcaption>
<h3>Parsley<span> Montana</span></h3>
<p>
That's the problem with nature, something's always stinging you or oozing mucous all over you. Hobbes, I think it is time you and me when and watched some TV.
</p>
</figcaption>
</figure>
</section>
Use text-align: center; on the section and remove float: left; on figure and use display: inline-block; and vertical-align: top; instead.
Should do the trick, see below snippet :
section {
width: 100%;
padding: 1rem;
display: table;
margin: 0 auto;
max-width: none;
background-color: #373B44;
height: 100vh;
text-align: center;
}
section:nth-of-type(2n) {
background-color: white;
}
figure.snip1165 {
display: inline-block;
vertical-align: top;
margin: 1rem;
overflow: hidden;
min-width: 150px;
max-width: 300px;
background: #000000;
color: #333;
text-align: left;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
<section>
<figure class="snip1165">
<img src="http://test.nationalparkpaws.com/images/camping%20in%20mountains%20with%20ten.jpg"/>
<figcaption>
<h3>Useful Tips</h3>
<p>
Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.
</p>
</figcaption>
</figure>
<figure class="snip1165 red">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample63.jpg" alt="sample63"/>
<figcaption>
<h3>Caspian<span> Bellevedere</span></h3>
<p>
I don't need to compromise on my principles, because they don't have the slightest bearing on what happens to me anyway.
</p>
</figcaption>
</figure>
<figure class="snip1165 orange">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample64.jpg" alt="sample64"/>
<figcaption>
<h3>Parsley<span> Montana</span></h3>
<p>
That's the problem with nature, something's always stinging you or oozing mucous all over you. Hobbes, I think it is time you and me when and watched some TV.
</p>
</figcaption>
</figure>
</section>
I am struggling to make a polaroid image like. In which the image have a text in the bottom. I tried every instruction but failed to do so.
Here is my HTML code
<div id="Places" class="gallery">
<ul>
<li>
<a href="https://www.w3schools.com/css/css_image_gallery.asp" target="_blank">
<img src="images/babot1.jpg" alt="bobat1">
</a>
</li>
<li>
<a href="https://www.w3schools.com/css/css_image_gallery.asp" target="_blank">
<img src="images/lhouse1.jpg" alt="bobat1">
</a>
</li>
<li>
<a href="https://www.youtube.com/playlist?list=PL6n9fhu94yhVm6S8I2xd6nYz2ZORd7X2v" target="_blank">
<img src="images/babot1.jpg" alt="bobat1">
</a>
</li>
</ul>
</div>
and this is my css code that I use
div.gallery{
border:2px solid #ddd;
margin:0 auto;
margin-top:100px;
margin-bottom:30px;
border-radius:3px;
width:98%;
}
div.gallery::before{
content: "";
clear: both;
display: table;
}
div.gallery ul{
list-style-type:none;
overflow:hidden;
margin:0 auto;
}
div.gallery li a img {
margin: 20px 20px 21px 20px;
width: 28.50%;
float:left;
padding-bottom:50px;
}
EDIT 1:
Here is the sample photo of what I got.
<figure> + <figcaption> have been designed for this.
To make it Polaroid like, here's what I'd do:
figure {
border: 1px solid #f5f5f5;
border-radius: 5px;
padding: 10px;
display: inline-block;
box-shadow: 0 4px 5px -2px rgba(0,0,0,.2), 0 7px 10px 1px rgba(0,0,0,.14), 0 2px 16px 1px rgba(0,0,0,.12);
}
figure img {
display: block;
}
figcaption {
display: block;
padding: 1rem 0 .5rem;
color: #777;
}
<figure>
<img src="http://placehold.it/350x250" />
<figcaption>This would be a caption</figcaption>
</figure>
<figure>
<img src="http://placehold.it/250x350" />
<figcaption>This would be another caption</figcaption>
</figure>
Please note you're currently floating the <img> tags. If you want the above to work, you need to remove the following from your current CSS:
div.gallery li a img {
margin: 20px 20px 21px 20px;
width: 28.50%;
float:left;
padding-bottom:50px;
}
You can float your <figure>s instead.
there is an html tag to do what you want:
<figure>
<img src="myImage.jpg" alt="my image">
<figcaption>This is my image</figcaption>
</figure>
Put your text inside a div, position it absolute and give it a z-index of 90 or higher.
<div id="txt">This is a title</div>
<style>
position: absolute;
z-index: 99;
</style>