sorry in advance for my english,
I have to reproduce this original
But I do this : my solution
Here it's my code :
div.psp div.picture-left img {
width: 45%;
margin-right: 1em;
float:left;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
<h2>Put some pictures</h2>
<div class="psp">
<div class="picture-left">
<figure>
<img src="images/cat.jpg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
<figcaption>A cat, just to keep the context of the website.</figcaption>
</figure>
</div>
<div class="tleft">
<p>
We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
Add some relevant pictures to give a little bit of context, or to cheer up the reader.
Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
web browser on a computer, you're not reading a book on a Kindle.
</p>
<p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>
<p>You see the picture of this cute cate? He's happy, and you should be too.</p>
</div>
</div>
I dont know why my figcaption move like that.
I thank you in advance.
change your IMG Style Like this
div.psp div.picture-left img {
width: 100%;
margin-right: 1em;
float:left;
}
then add css class .picture-left
like this
.picture-left {
width:45%;
}
then add CSS class .psp like this
.psp{
display: flex;
}
try this if you have any doubt comment me
and don't use bad words on public platform postsā
div.psp div.picture-left img {
width: 100%;
margin-right: 1em;
float:left;
}
.picture-left {
width:45%;
}
.psp{
display: flex;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
<h2>Put some pictures</h2>
<div class="psp">
<div class="picture-left">
<figure>
<img src="https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
<figcaption>A cat, just to keep the context of the website.</figcaption>
</figure>
</div>
<div class="picture-left">
<p>
We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
Add some relevant pictures to give a little bit of context, or to cheer up the reader.
Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
web browser on a computer, you're not reading a book on a Kindle.
</p>
<p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>
<p>You see the picture of this cute cate? He's happy, and you should be too.</p>
</div>
</div>
It happned because you floated the image to left.
Thats why it is going on the side.
Just don't select the img tag, Like this:
div.psp div.picture-left { /* <---- Just remove the img */
width: 45%;
margin-right: 1em;
float:left;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
Related
I'm having a hard time figuring out how to put my image right beside my paragraph. The goal is to set an image beside my text, not super close but on the same line. How can I do this in css? Below is my About.js and About.css. My paragraph is wrapped in a div called about-page. I tried taking my img tag outside that div but it causes an error. It's suppose to look like this sketch below.
import React from 'react'
import '../CSS/About.css'
import clock from '../clock.jpg'
const About = () => {
return (
<div className="about-page">
<h6 className="about-this-app-header">About This Application</h6>
<p className="description">
Do You Have A Habit of Forgetting Stuff? Don't Worry!!!
<br />
Here's <b>Reminder Me</b> to The Rescue.
</p>
<p className="description">
<b>Reminder Me</b> is a reminder management application
<br />
that lets you send reminders through text message.
<br />
It lets you set a time/duration and a message for your
<br />
reminder. And makes sure that it's sending out right on
<br />
time, not letting you or your friends miss out on the
<br />
important things in life.
</p>
<h6 className="tech-stack-header">Tech Stack</h6>
<h6 className="tech-stack">Front-End: <p className="tech">React, Materialize UI, Font Awesome</p></h6>
<h6 className="tech-stack">
Back-End: <p className="tech">Express.js, Firebase, Node.js, Twilio API</p>
</h6>
<h6 className="link-to">
Link to:
<a
href="https://github.com/jspades93?tab=repositories"
target="_blank"
rel="noopener noreferrer"
className="waves-effect waves-light btn-flat"
>
<i className="fa fa-github" style={{ fontSize: "36px" }}></i>
</a>
</h6>
<div className="clock-image"><img src={clock} alt="clock" /></div>
</div>
);
};
export default About
h6 {
font-weight: bold;
color: #056674;
}
.btn-flat {
color: black;
}
.about-this-app-header {
margin-top: 100px;
margin-left: 170px;
}
.description {
margin-top: 20px;
margin-left: 90px;
}
.tech-stack-header{
margin-top: 25px;
margin-left: 210px;
}
.tech-stack {
margin-left: 90px;
}
.link-to {
margin-left: 35px;
margin-top: 20px;
}
img {
width: 390px;
height: 250px;
float: right;
}
.tech {
display: inline;
vertical-align: top;
color: black;
font-weight: normal;
}
I wouldn't advice using CSS floats, you can use flex box but this way of work adds more divs to the DOM only to set the locations as needed.
I'd recommend using CSS grid, less DOM nodes required, less messy CSS. You can read all about it here. You have a more details expiation here or here.
Basically you would want to set a grid for the container and set the header, the left and right parts.
Something like so
.about-page {
display: grid;
grid-template-areas:
'header header'
'description image';
grid-gap: 10px;
}
.clock-image { grid-area: image; }
.header { grid-area: header; }
.about { grid-area: description; }
You should use floats like this example:
use float: left; for your text and use float: right; for your image.
.left {
float:left;
}
.right {
float:right;
}
figure img {
margin:10px;
width: 50%;
}
figcaption {
font-family:sans-serif;
font-weight:bold;
font-size:16px;
padding:10px;
}
.clear {
clear:both;
}
.centered {
margin: auto; /* margin:auto centers the figure element */
width: 50%;
background:#ccc;
text-align:center; /* text-align centers the text and image only - you need margin:auto to center the entire figure */
}
<figure> <img src="https://c1.staticflickr.com/9/8597/29295139165_94394aba37_z.jpg" width="640" height="427" alt="A_Dog Day 2016 at Andy Memorial Skate Park in Burlington, VT" class="left">
<figcaption> This is the caption for a left-floated photo. This element's width is has not been set and it will run the full width of the page. This is the caption for a left-floated photo. This element's width is has not been set and it will run the full width
of the page. </figcaption>
</figure>
<div class="clear"></div>
<figure> <img src="https://c1.staticflickr.com/9/8597/29295139165_94394aba37_z.jpg" width="640" height="427" alt="A_Dog Day 2016 at Andy Memorial Skate Park in Burlington, VT" class="right">
<figcaption> This is the caption for a right-floated photo. This div in between figures with the clear:both property clears the float from the div above it, so the next div can have a different or no float. </figcaption>
</figure>
<div class="clear"></div>
<figure class="centered"><img src="https://c1.staticflickr.com/9/8597/29295139165_94394aba37_z.jpg" width="640" height="427" alt="A_Dog Day 2016 at Andy Memorial Skate Park in Burlington, VT">
<figcaption class="centered-text"> Tip: margin:auto ONLY works if the width property is set, and not set to 100%, so the margins can push the less-than-full-width element into the middle. </figcaption>
</figure>
</div>
I am trying to do two things:
1) Make the three pictures float side by side
2) Create a border filled with the text in the p element below each picture.
Here is an idea of what I am trying to achieve.
Here is what I've done so far...
<div class="fitness-section">
<h1>Get fit</h1>
<img src="images/EssentialWorkouts.png" alt="essentialworkouts" class="essential">
<h5>Essential Workouts</h5>
<p>Going to a gym is definitely the best way to transform and build your body.
However, It is common for many people especially new-gymmers to feel nervous,
intimidated and lost in the gym. There are many effective and essential
workouts that are bound to get you ripped and buff in no time!</p>
Find out more
</div>
<div class="fitness-section">
<img src="images/Motivation.png" alt="motivation" class="motivation">
<p>Have you ever felt unmotivated and lost your will to gym? Fret not, there are
many inspirational quotes and articles here that will help you generate and
maintain a flow of positive attitude to keep you motivated to achieve your
fitness and goals in life!</p>
Find out more
</div>
<div class="fitness-section">
<h1>Get fit</h1>
<img src="images/Shoe.png" alt="shoe" class="shoe">
<p>Working out in the gym with a proper attire is an absolute neccessity to achieve
the best workout possible. Wearing attire that is too tight or too loose will
definitely affect your workouts. Discover and find out what you should and
should not be wearing in the gym.</p>
Find out more
</div>
Here's some work to start you off.
html, body {
box-sizing: border-box;
}
h1 {
text-align: center;
}
.wrapper {
text-align: center;
}
p {
text-align: left;
margin-top: 20px;
border: 1px solid #000;
padding: 10px;
height: 150px;
}
.fitness-section {
display: inline-block;
vertical-align: top;
padding: 10px;
margin-right: -4px;
width: 300px;
}
https://codepen.io/anon/pen/MvyeEN
I can recommend you, to use diffrent classes for your boxes
<div class="fitness-section div1">
<h1>Get fit</h1>
<img src="images/EssentialWorkouts.png" alt="essentialworkouts" class="essential">
<h5>Essential Workouts</h5>
<p>Going to a gym is definitely the best way to transform and build your body.
However, It is common for many people especially new-gymmers to feel nervous,
intimidated and lost in the gym. There are many effective and essential
workouts that are bound to get you ripped and buff in no time!</p>
Find out more
</div>
<div class="fitness-section div2">
<img src="images/Motivation.png" alt="motivation" class="motivation">
<p>Have you ever felt unmotivated and lost your will to gym? Fret not, there are
many inspirational quotes and articles here that will help you generate and
maintain a flow of positive attitude to keep you motivated to achieve your
fitness and goals in life!</p>
Find out more
</div>
<div class="fitness-section div2">
<h1>Get fit</h1>
<img src="images/Shoe.png" alt="shoe" class="shoe">
<p>Working out in the gym with a proper attire is an absolute neccessity to achieve
the best workout possible. Wearing attire that is too tight or too loose will
definitely affect your workouts. Discover and find out what you should and
should not be wearing in the gym.</p>
Find out more
</div>
And for style use this:
.fitness-section {
width: 30%;
}
.div1 {
float: left;
background-color: red;
margin: 15px 15px;
}
.div2 {
float: left;
background-color: blue;
margin: 15px 15px;
}
div3 {
float: right;
background-color:yellow;
margin: 15px 15px;
}
For some reason text1 goes to the next column instead of under the image like it should unless i use a clear tag. The problem with using a clear tag is i cannot add text2 around where text1 was previously before the clear tag which is why you see a big space before the paragraphs.
Also text-align doesn't center text on the page. It centers text around its contents. How do i fix this?
Jsfiddle - https://jsfiddle.net/p6eocccj/
HTML
<div id="div1">
<p id="text0"><span id="sp1pg4">About me</span></p>
<img id="img1" src ="images/hack.jpg"/>
<br>
<p id="text1"><strong>Image Courtesy Homer Simpson</strong><br></br>
www.homersimpsoniscooltoo.com</p>
<p id="text2">
Hi there!
<br></br>
I'm bob, a coool designer and developer<br>
from Far far coolioland, Australia. I<br>
specialise in cooking, shipping, shopping,<br>
camping and turning coffee into popcorn. My<br>
approach to buytying is this, make it clean and<br>
simple but also focus on the buying for men. This<br>
is what differentiates poor people from great chimps.<br>
Whether you want to build a house for as long as<br>
business, a personal toy or just ask you some<br>
</p>
</div>
CSS
#div1 {
width: max-width;
height: 1650px;
background-color: #ECECEC;
}
#text0 {
text-align: left;
padding-top: 25px;
padding-left:150px;
}
#img1 {
float:left;
margin-top: 25px;
margin-left:150px;
width: 220px;
height: 220px;
border-radius: 50%;
}
#text1 {
clear:left;
float:left;
padding-left:160px;
font-size:13px;
line-height:80%;
}
#text2 {
padding-top: 100px;
line-height: 140%;
text-align: center;
font-family: sans-serif;
font-size: 15px;
}
Because when you apply float rule to any element then that element is not part of Normal Document Flow and it will wrap texts around it. Either remove float or use clearfix hack.
Here is clearfix hack-
.clearfix::after {
display: table;
content: '';
clear: both;
}
P.S: I have just removed float: left from image. If you want to use hack then apply clearfix class to parent of image.
#div1 {
width: max-width;
height: 1650px;
background-color: #ECECEC;
}
#text0 {
text-align: left;
padding-top: 25px;
padding-left:150px;
}
#img1 {
margin-top: 25px;
margin-left:150px;
width: 220px;
height: 220px;
border-radius: 50%;
}
#text1 {
clear:left;
float:left;
padding-left:160px;
font-size:13px;
line-height:80%;
}
#text2 {
padding-top: 100px;
line-height: 140%;
text-align: center;
font-family: sans-serif;
font-size: 15px;
}
<div id="div1">
<p id="text0"><span id="sp1pg4">About me</span></p>
<img id="img1" src ="images/hack.jpg"/>
<br>
<p id="text1"><strong>Image Courtesy Homer Simpson</strong><br></br>
www.homersimpsoniscooltoo.com</p>
<p id="text2">
Hi there!
<br></br>
I'm bob, a coool designer and developer<br>
from Far far coolioland, Australia. I<br>
specialise in cooking, shipping, shopping,<br>
camping and turning coffee into popcorn. My<br>
approach to buytying is this, make it clean and<br>
simple but also focus on the buying for men. This<br>
is what differentiates poor people from great chimps.<br>
Whether you want to build a house for as long as<br>
business, a personal toy or just ask you some<br>
</p>
</div>
Because you add float left to to image tag..remove float on image or add clear to text elements
I have a <h2 class="landing-panel-title> with a <span class="landing-panel-icon-right ion-ios-search-strong> nested inside. The second class on the span comes from a custom icons font called ionicons and is probably not relevant.
This is a header accompanied by an icon. I want to put a margin between the icon and the title (I want the icon on the far right when after text, and the text on the far right when the icon is on the left of the text), that auto expands as much as it can. I tried achieving this with text-align, but so far haven't been able to get it to work.
http://jsfiddle.net/eakfsLr3/
HTML:
<div class="landing-panel">
<h2 class="landing-panel-title">Site Reviews<span class="landing-panel-icon-right ion-ios-search-strong"></span></h2>
<p class="landing-panel-text">I have been searching for different PTC sites, collecting knowledge and data, testing the theories, and made a general collection of what I found useful and relevant.</p>
</div>
<div class="landing-panel">
<h2 class="landing-panel-title"><span class="landing-panel-icon-left ion-erlenmeyer-flask"></span>Methodical Approach</h2>
<p class="landing-panel-text">We have collected data and tested the relevant info through my partner in crime, and he's using our guides and the knowledge to build his career in PTCs.</p>
</div>
<div class="landing-panel">
<h2 class="landing-panel-title">Results<span class="landing-panel-icon-right ion-clipboard"></span></h2>
<p class="landing-panel-text">We won't serve you bullshit, we give you relevant information that our staff has deemed legit and working. Enjoy the read!</p>
</div>
CSS:
.landing-panel {
background-color: #d5f5e3;
padding: 0.5em;
margin-bottom: 0.5em;
}
.landing-panel-title {
width: 100%;
}
.landing-panel-icon-right, .landing-panel-icon-left {
color: #913D88;
font-size: 3em;
}
.landing-panel-icon-right {
text-align: right;
}
.landing-panel-icon-left {
text-align: left;
}
.landing-panel-title, .landing-panel-icon, .landing-panel-text {
margin: 0;
padding: 0;
}
Any help is appreciated.
If I understood correctly, you want this? http://jsfiddle.net/sergdenisov/yv2xazjh/1/
.landing-panel {
background-color: #d5f5e3;
padding: 0.5em;
margin-bottom: 0.5em;
}
.landing-panel-title {
display: table-cell;
width: 100%;
}
.landing-panel-icon {
display: table-cell;
color: #913D88;
font-size: 3em;
}
.landing-panel-title, .landing-panel-icon, .landing-panel-text {
margin: 0;
padding: 0;
}
.landing-panel-icon + .landing-panel-title {
text-align: right;
}
<div class="landing-panel">
<h2 class="landing-panel-title">Site Reviews</h2>
<span class="landing-panel-icon ion-ios-search-strong">Icon</span>
<p class="landing-panel-text">I have been searching for different PTC sites, collecting knowledge and data, testing the theories, and made a general collection of what I found useful and relevant.</p>
</div>
<div class="landing-panel">
<span class="landing-panel-icon ion-erlenmeyer-flask">Icon</span>
<h2 class="landing-panel-title">Methodical Approach</h2>
<p class="landing-panel-text">We have collected data and tested the relevant info through my partner in crime, and he's using our guides and the knowledge to build his career in PTCs.</p>
</div>
<div class="landing-panel">
<h2 class="landing-panel-title">Results</h2>
<span class="landing-panel-icon ion-clipboard">Icon</span>
<p class="landing-panel-text">We won't serve you bullshit, we give you relevant information that our staff has deemed legit and working. Enjoy the read!</p>
</div>
Make your span class as display:inline-block
span {
display:inline-block; /*this enables margins to work*/
margin: 0 10px;
}
Try
.landing-panel-title>span{
width:..px /*set as much required */
display:inline-block;
text-align:center;/* left/right */
}
or if You just want a small margin between them, then put before span element
or if you just want icon to be on the right of the header then-
.landing-panel-title>span{
position:absolute;
right:0;
/* This would make icon always at right */
}
I am currently working on an About Me page, and I want the text box to set to the left of the screen and a picture to run inline with the text, but for some reason I can only get the picture to show up underneath. Could someone please tell me what I doing wrong? Thank you.
HTML
<div class="about_me">
<h2 class="about">about me</h2>
<p class="bio">I am a Front End Designer that hails from Cadillac, MI. I have a deep understanding on HTML and CSS, and love designing and coding websites. I enjoy taking your problems and turning them into solutions. Whether you need a simple logo or an entire website, I can get it done for you. </p>
</div>
<div class="family">
<img src="images/family1.jpg" alt="family">
</div>
CSS
.about_me {width: 500px;
height: auto;
border:none;
visibility: visible;
right: 0%;
opacity: 1;
}
.about {font-size: 45pt;
font-family: Zumba Fitness Official Typeface;}
.bio {font-family: arial;
font-size: 14pt;
}
.family {visibility: visible;
left: 0%;
opacity: 1;
}
.aboutme {float: left;}
Try that.
add display: inline-block; to the .about_me and .family classes both, and remove left and right properties from the both classes. also add 'float: left;' to the .about_me class.
You need to create class in left for image and right for text.
<div style="width: 100%">
<img style="float:right;">