Context and example
For context, I just recently started coding to make a website as a project I’ve wanted to do. Right now I have a placeholder image that when clicked is supposed to send you back to the main part of the site but I cant get the image to move away from the text its in a <div>
with
Currently what the site looks like:
I tried so far to use css to make the margin or padding on the text block to push the image away But the image itself wont budge but I can put padding on the image and it pushes the text away.
Sending below the code I currently have with html and css
This is what I want the top to look like:
.intpage {
display: flex;
justify-content: center
}
.Image {
float: left;
}
.text {
text-align: center;
font-size: 60px;
margin-left: 70px;
float: left;
color: #ffffff;
}
body {
background-color: #c78df7;
}
p {
text-align: center;
font-family: 'Lucida Console', "Lucida Console", monospace;
}
<div class="intpage">
<div class="Image">
<a href="https://aechcreations.github.io"><img src="Imagess/pholdr.png" alt="placeholder" width="132" height="132" onmouseover="this.src='Imagess/pholdr2.png'" onmouseout="this.src='Imagess/pholdr.png'" />
</a>
</div>
<div class="Text">
<h1> testing </h1>
</div>
</div>
<p> this is a test that I think is working </p>
2
Answers
If you want your content to be inline you need to wrap it in a div and use display: flex and flex-direction:row (if you use column (.intpage) it will stack child elements verticaly). Check this code hope it helps
As the class
.intpage
‘s display property is flex, you don’t need to make the imagefloat:left
. removefloat:left
The classes
.Image
and.Text
should be made into percentage as you wanth1
to be centered (Note: The class name given in css is.test
and the class name given in html isTest
. Class names are case sensitive)For the image provide only width and mention height as
auto
Add
align = "center"
in the img tag as the img tag is a child of the class.Image
For the sake of understanding, Font-size of
.Test
, I’ve reduced to 30px.Remove
float:left
in the class.Test
. Thetext-align:center
will conflict tofloat:left
. If you want this to be in left changetext-align:center
totext-align:left
h1
will be in the center of the right side portion (85%), and<p>
will be in the center of the whole screen width. This may make you to think that it is not properly aligned. So, for you to understand, I’have added a line separating two divisions. To remove this remove<hr size="3" color="white">
from html.Checked with a dummy image. Screenshot
Placed the css between tag. You can remove and paste into separate css file.