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>
Related
I am starting as a developper front-end and learning to code in HTML and CSS.
I am struggling with the last section of my code, there is a big empty space, I am trying to find a solution but never could, if someone can help me, that would be perfect !
Also I would like to know what I did wrong, it'll help me to learn even more :)
Here the empty spot
Thanks in advance !!
.activites {
width: 100%;
display: flex;
}
.colonnesimple {
width: 25%;
display: flex;
flex-direction: column;
align-items: center;
}
.colonnedouble {
width: 25%;
display: flex;
flex-direction: column;
}
.colonnesimple img {
object-fit: cover;
height: 90%;
width: 100%;
border-radius: 16px 16px 0 0;
}
.colonnedouble img {
object-fit: cover;
height: 80%;
width: 100%;
border-radius: 16px 16px 0 0;
}
.activites .colonnesimple figure {
width: calc(100% / 1.2);
height: 59%;
margin-left: 25px;
margin-right: 40px;
box-shadow: 0px 0px 10px #55555538;
border-radius: 16px 16px 16px 16px;
cursor: pointer;
}
.activites .colonnedouble figure {
width: calc(100% / 1.2);
height: 28%;
margin-left: 30px;
margin-right: 40px;
box-shadow: 0px 0px 10px #55555538;
border-radius: 16px 16px 16px 16px;
cursor: pointer;
}
.activites .colonnesimple figure figcaption {
padding: 10px;
position: relative;
}
.activites .colonnedouble figure figcaption {
padding: 10px;
position: relative;
}
<section id="activitesmarseille">
<div class="contenuactivites">
<h5>Activités à Marseille</h5>
<div class="activites">
<div class="colonnesimple">
<figure>
<a href="#">
<img class="imagesolo" src="images/activites/3_medium/reno-laithienne-QUgJhdY5Fyk-unsplash.jpg" alt="Image du Vieux Port">
<figcaption>
<h6>Vieux Port</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnedouble">
<figure>
<a href="#">
<img class="imagedoublegrd" src="images/activites/3_medium/paul-hermann-QFTrLdQIRhI-unsplash.jpg" alt="Image du Fort de Pomègues">
<figcaption>
<h6>Fort de Pomègues</h6>
</figcaption>
</a>
</figure>
<figure>
<a href="#">
<img class="imagedoublept" src="images/activites/3_medium/kevin-hikari-rV_Qd1l-VXg-unsplash.jpg" alt="Image des îles du Frioul">
<figcaption>
<h6>îles du Frioul</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnesimple">
<figure>
<a href="#">
<img class="imagesolo" src="images/activites/3_medium/kilyan-sockalingum-NR8-cBCN3aI-unsplash.jpg" alt="Image du Parc National des Calanques">
<figcaption>
<h6>Parc National des Calanques</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnedouble">
<figure>
<a href="#">
<img class="imagedoublept" src="images/activites/3_medium/florian-wehde-xW9e8gdotxI-unsplash.jpg" alt="Image de Notre-Dame-de-la-Garde">
<figcaption>
<h6>Notre-Dame-de-la-Garde</h6>
</figcaption>
</a>
</figure>
<figure>
<a href="#">
<img class="imagedoublegrd" src="images/activites/3_medium/lena-paulin-wH2-EJoDcV0-unsplash.jpg" alt="Image du Parc LongChamp">
<figcaption>
<h6>Parc LongChamp</h6>
</figcaption>
</a>
</figure>
</div>
</div>
</div>
</section>
So problem was with height: 59%; which u provide at %, because that u have empty space on the end of the page, solution:
.activites {
width: 100%;
display: flex;
}
.colonnesimple {
width: 25%;
}
.colonnedouble {
width: 25%;
flex-direction: column;
}
.colonnesimple img {
object-fit: cover;
height: 90%;
width: 100%;
border-radius: 16px 16px 0 0;
}
.colonnedouble img {
object-fit: cover;
height: 80%;
width: 100%;
border-radius: 16px 16px 0 0;
}
.activites .colonnesimple figure {
width: calc(100% / 1.2);
height: 257px;
margin-left: 25px;
margin-right: 40px;
box-shadow: 0px 0px 10px #55555538;
border-radius: 16px 16px 16px 16px;
cursor: pointer;
}
.activites .colonnedouble figure {
width: calc(100% / 1.2);
height: 120px;
margin-left: 30px;
margin-right: 40px;
box-shadow: 0px 0px 10px #55555538;
border-radius: 16px 16px 16px 16px;
cursor: pointer;
}
.activites .colonnesimple figure figcaption {
padding: 10px;
position: relative;
}
.activites .colonnedouble figure figcaption {
padding: 10px;
position: relative;
}
<section id="activitesmarseille">
<div class="contenuactivites">
<h5>Activités à Marseille</h5>
<div class="activites">
<div class="colonnesimple">
<figure><a href="#">
<img class="imagesolo" src="https://www.imgacademy.com/sites/default/files/2009-stadium-about.jpg" alt="Image du Vieux Port">
<figcaption>
<h6>Vieux Port</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnedouble">
<figure><a href="#">
<img class="imagedoublegrd" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSe6kwbxkuKpLxeNP_O6LGoJxIkuhatjNvZ0gPcRr4DpziONgkIsqNOl09dfZduQJHH_6k&usqp=CAU" alt="Image du Fort de Pomègues">
<figcaption>
<h6>Fort de Pomègues</h6>
</figcaption>
</a>
</figure>
<figure><a href="#">
<img class="imagedoublept" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTRnsZZ1ZwCEhb4spOX3eIMeN3KbwZaAJo6mypioWrvsaNPfb5TFNu8kjrtEvrADqvoRdA&usqp=CAU" alt="Image des îles du Frioul">
<figcaption>
<h6>îles du Frioul</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnesimple">
<figure><a href="#">
<img class="imagesolo" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT2qwQpNH5dPV0dLoPl7InPlMPUf0eWWMG4POrt56FeF62yCUZA-qVBMKb3UDi6I2lj30k&usqp=CAU" alt="Image du Parc National des Calanques">
<figcaption>
<h6>Parc National des Calanques</h6>
</figcaption>
</a>
</figure>
</div>
<div class="colonnedouble">
<figure><a href="#">
<img class="imagedoublept" src="https://www.imgacademy.com/sites/default/files/styles/scale_2500w/public/2017-03/Campus%20Center.jpg?itok=Bs2r8s-1" alt="Image de Notre-Dame-de-la-Garde">
<figcaption>
<h6>Notre-Dame-de-la-Garde</h6>
</figcaption>
</a>
</figure>
<figure><a href="#">
<img class="imagedoublegrd" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTGOfJEHAIvVjPI8TXLLrMgwXWZiPx0FkU3dBiBExfIDy-ISANxSh2ulIvA9f86y_yu-sU&usqp=CAU" alt="Image du Parc LongChamp">
<figcaption>
<h6>Parc LongChamp</h6>
</figcaption>
</a>
</figure>
</div>
</div>
</div>
</section>
If you encounter more problems like this I advice to use the inspector (CTRL+SHIFT+C) of your browser
and simply hover over the problem to see where the problem may be. In this case probably a height value that is too high.
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'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;
}
I have translated an image up to go behind a div to make it fit the design, however it leaves a white space below it, where the original image would be. How would I go about fixing this?
This is for a website, I've tried translating the sitemap up however then there is even more white space below the sitemap.
HTML:
<div class="portfolioImage" id="images">
<div class="portLogoImages" id="myDIV5">
<img src="./resources/portfolio/logoportfolio/logoPortfolio1.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio2.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio3.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio4.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio5.png" alt="" class="portfolioImages">
</div>
</div>
<div class="sitemap portAdjustment"> <!-- SITEMAP -->
<div class="sitemapItems">
<img src="./resources/sitemapLogo.png" alt="" class="sitemapLogo" width="166.3px" height="22px">
<div class="links">
<p >Home</p>
<p>Products</p>
<p>Portfolio</p>
<p>About Us</p>
<p>Contact Us</p>
</div>
<div class="finePrint">
<p>X is a part of the family company X that specialises in custom made design ranging from logo design to apparel design.</p>
<p>X</p>
</div>
</div>
</div>
CSS:
.portfolioImages {
border: none;
font-size: 0px;
transform: translateY(-25px);
max-width: 100%;
}
.portLogoImages {
border: none;
font-size: 0px;
transform: translateY(-25px);
max-width: 100%;
height: auto;
width: 100%;
margin-left: auto;
margin-right: auto;
}
.sitemap {
width: 100%;
height: 215px;
background-color: #f4f4f4;
padding: 30px 0px 30px 0px;
display: block;
text-align: center;
}
.finePrint {
padding-top: 70px;
color: #c8c8c8;
}
.sitemapItems {
padding: 0px 30px 0 30px;
display: block;
}
.sitemap a {
text-decoration: none;
color: #c8c8c8;
transition-duration: .2s;
display: inline-block;
padding-right: 4px;
}
.sitemap a:hover {
text-decoration: underline;
color: #434343;
}
I expect there to be no white space however there is still white space below it.
Just use margin-top instead transform
the work waiting to be done
I want them to be fixed on size; like a table without shared borders.
Here s my html and css codes:
.leftsubstancelist {
padding-top: 40px;
border-top: 2px solid #003333;
width: 39%;
float: left;
}
.rightsubstancelist {
padding-top: 40px;
border-top: 2px solid #003333;
width: 39%;
float: right;
}
.leftsubstancelist figure {
border: 3px solid #003333;
}
.rightsubstancelist figure {
border: 3px solid #003333;
}
figure img {
max-width: 80%
}
<section class="leftsubstancelist">
<figure>
<img src="img/active_substance/vankomisin.png" alt="Vankomisin Hidroklorür" align="center">
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
<br>
<figure>
<img src="img/active_substance/imipenem_silastatin.png" alt="İmipenem / Silastatin" align="center">
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
</section>
<section class="rightsubstancelist">
<figure>
<img src="img/active_substance/ertapenem.png" alt="Ertapenem" align="center">
<figcaption>Ertapenem</figcaption>
</figure>
<br>
<figure>
<img src="img/active_substance/teikoplanin.png" alt="Teikoplanin" align="center">
<figcaption>Teikoplanin</figcaption>
</figure>
</section>
I ve tried, display:box, align:center and some other related stuff but couldn't manage to tidy them up.
Thanks for your help!
Use flexbox.
When you want all rows to be of a continuous height, you could leave out align-items or set it to stretch. Otherwise you could use align-items: flex-start when you want them to have an individual height but rendered at top.
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
section {
display: flex;
justify-content: space-between;
/* Uncomment the following line, if the
rows cell can have different heights */
/* align-items: flex-start; */
flex-wrap: wrap;
border-top: 2px solid #003333;
padding: 20px;
}
figure {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border: 3px solid #003333;
width: calc( 50% - 40px );
margin: 20px;
}
figure img {
width: 100%;
height: auto;
}
<section>
<figure>
<img src="http://via.placeholder.com/320x140" />
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x160" />
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x180" />
<figcaption>Ertapenem</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/320x120" />
<figcaption>Teikoplanin</figcaption>
</figure>
</section>
Try below:
<style>
.divSquare1{
width:45%; height:200px; margin:4px; border:1px solid black; float: left
}
.divSquare2{
width:45%; height:200px; margin:4px; border:1px solid black; float: right
}
.space{
width:5%;
}
</style>
<div class="divSquare1">
<figure>
<img src="img/active_substance/vankomisin.png" alt="Vankomisin Hidroklorür" align="center">
<figcaption>Vankomisin Hidroklorür</figcaption>
</figure>
</div>
<div class="divSquare2">
<figure>
<img src="img/active_substance/imipenem_silastatin.png" alt="İmipenem / Silastatin" align="center">
<figcaption>İmipenem / Silastatin</figcaption>
</figure>
</div>
<div style='clear:both' class="space"></div>
<div class="divSquare1">
<figure>
<img src="img/active_substance/ertapenem.png" alt="Ertapenem" align="center">
<figcaption>Ertapenem</figcaption>
</figure>
</div>
<div class="divSquare2">
<figure>
<img src="img/active_substance/teikoplanin.png" alt="Teikoplanin" align="center">
<figcaption>Teikoplanin</figcaption>
</figure>
</div>
Set a static height for your figure element. This will make them all have the same height and spacing. I believe this will solve your issue but your question was vague.
figure {
height: 150px;
}