Div to image next to each other - html

I don't know how and where to put the image in the structure so that it displays on the right side of the users screen.
I tried using float left, float right, on the specific html elements with width of 40% and 60%.. But the problem is that it will split the Paragraph smaller, but i don't want that to happen. Everything should stay in place, same height, width, but the image should be on the right side of the Screen while the text is on the same height, on the left.
.textl {
float: left;
display: grid;
place-items: left;
align-content: center;
text-align: left;
min-height: 20vh;
padding-left: 10%;
padding-top: 10%;
}
#textl-p {
width: 40%;
}
h1 {
font-size: 4rem;
margin-bottom: 20px;
font-family: Montserrat;
font-weight: 100;
color: white;
}
p {
font-size: 1.5rem;
font-family: Poppins;
font-weight: 300;
justify-content: justify;
color: white;
}
.button {
padding: 9px 20px;
border: 2px solid white;
border-radius: 90px;
width: 10%;
margin-top: 1%;
transition: 0.3s ease 0s;
text-align: center;
font-family: Poppins;
}
/* added by community for clarity */
body {
background: #aaa;
}
<div class="textl">
<h1 id="welcome">Guten Tag</h1>
<p id="textl-p" ">
example text
</p>
<div class="button ">examplebutton</div>
</div>
<img src="https://via.placeholder.com/100 ">

Related

Why is the <div> element not filling the rest of the screen wen I use height: 100%;

I am making a sidebar for my site and I want the side bar to fill the rest of the screen but also scroll separate to the right of the screen when it overflows with other elements inside. When I use 100% for the height the element only goes to the height of the last element inside of it.
I am trying to get it to fill the rest of the screen as I stated previously but it only goes to not all the way.
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.main {
margin-left: 345px;
border: 0px solid #ffffff;
padding: 0px 0px;
flex-direction: column;
align-content: center;
text-align: center;
width: 450px;
}
.card {
display: inline-block;
width: 400px;
height: 160px;
background-color: #404040;
border: 1px solid #404040;
border-radius: 4px;
margin: 0px;
margin-top: 20px;
text-decoration: none;
}
.toptext {
display: inline-block;
width: 400px;
height: 45px;
color: #ffffff;
background-color: #ffffff;
border: 1px solid #ffffff;
border-radius: 4px;
margin: 0px;
margin-top: 5px;
text-decoration: none;
text-align: left;
}
.toptext h1 {
font-size: 20px;
margin-left: 0px;
margin-top: 1px;
color: #404040;
}
.toptext p {
font-size: 12px;
margin-left: 0px;
margin-top: -10px;
color: #404040;
}
.flexcolumn {
flex-direction: column;
}
.leftmain {
height: 100%;
width: 325px;
padding: 0px 10px;
flex-direction: column;
align-content: center;
background-color: #333333;
overflow: scroll;
}
.leftmain p {
float: left;
color: #ffffff;
text-align: left;
padding: 0px 10px;
text-decoration: none;
font-size: 12px;
line-height: 25px;
border-radius: 4px;
background-color: #333333;
width: 300px;
}
.leftmain p:hover {
background-color: #404040;
color: #ffffff;
}
.header {
overflow: hidden;
background-color: #404040;
padding: 10px 10px;
height: 36px;
text-align: center;
}
.header-right {
float: right;
padding: 0px 0px;
}
.header a {
float: left;
color: #ffffff;
text-align: center;
padding: 5px 10px;
text-decoration: none;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
align-content: center;
}
.header a:hover {
background-color: #333333;
color: #ffffff;
}
<div class="header">
📄 My Paper Company
<div class="header-right">
Settings
Contact
Donate
<div class="flexcolumn">
</div>
</div>
</div>
<div id="leftmain" class="leftmain">
<p id="button" div="leftmain" onclick='show("htpmain")'>📢 How To Play</p>
</div>
<center>
<div id=htpmain class="main">
<div class="toptext">
<h1>
📢 How To Play
</h1>
<p>This guide will get you start the game and will be helpful to grasp everything you need to do.
</p>
</div>
<div class="card" />
</div>
</center>
Your leftmain IS taking up 100% of the space available to it, leftmain stops when it reaches . You have leftmain set to flex-direction: column;
when only the .main should have it. Also don't use the tag, it is no longer supported in HTML5 and is display: block; when it should be inline-block.
I would change just to and set display to inline-block and set a width so the leftmain has room to go past it.
I hope this solves your problem.
.leftmain {
height: 100%;
width: 325px;
padding: 0px 10px;
align-content: center;
background-color: #333333;
overflow: scroll;
}
#nameOfCenterDiv {
position: absolute;
left: 300px;
display: inline-block;
}
Give to the sidebar a position fixed so it always stays there wherever you scroll and and a margin-left to your content on the right (the width of the margin-left must be the same of sidebar width)
.leftmain{
position: fixed
}
.main{
margin-left: 345px;
width: 450px //remove this so it's 100%
}
You have to wrap the left sidebar and right panel within the same container.
Using the display: flex on the container, you no longer need to specify a 100% height for the left sidebar since it will automatically fill in the remaining space.
You also need to remove the margin-left rule for the right content so that it lays nicely with the sidebar.
You can optionally set a max-height of 100vh to the sidebar so that it scrolls when its content exceeds the viewport height.
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.main {
border: 0px solid #ffffff;
padding: 0px 0px;
flex-direction: column;
align-content: center;
text-align: center;
width: 450px;
}
.card {
display: inline-block;
width: 400px;
height: 160px;
background-color: #404040;
border: 1px solid #404040;
border-radius: 4px;
margin: 0px;
margin-top: 20px;
text-decoration: none;
}
.toptext {
display: inline-block;
width: 400px;
height: 45px;
color: #ffffff;
background-color: #ffffff;
border: 1px solid #ffffff;
border-radius: 4px;
margin: 0px;
margin-top: 5px;
text-decoration: none;
text-align: left;
}
.toptext h1 {
font-size: 20px;
margin-left: 0px;
margin-top: 1px;
color: #404040;
}
.toptext p {
font-size: 12px;
margin-left: 0px;
margin-top: -10px;
color: #404040;
}
.flexcolumn {
flex-direction: column;
}
.container {
display: flex;
}
.leftmain {
width: 325px;
padding: 0px 10px;
flex-direction: column;
align-content: center;
background-color: #333333;
overflow: scroll;
}
.leftmain p {
float: left;
color: #ffffff;
text-align: left;
padding: 0px 10px;
text-decoration: none;
font-size: 12px;
line-height: 25px;
border-radius: 4px;
background-color: #333333;
width: 300px;
}
.leftmain p:hover {
background-color: #404040;
color: #ffffff;
}
.header {
overflow: hidden;
background-color: #404040;
padding: 10px 10px;
height: 36px;
text-align: center;
}
.header-right {
float: right;
padding: 0px 0px;
}
.header a {
float: left;
color: #ffffff;
text-align: center;
padding: 5px 10px;
text-decoration: none;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
align-content: center;
}
.header a:hover {
background-color: #333333;
color: #ffffff;
}
<div class="header">
📄 My Paper Company
<div class="header-right">
Settings
Contact
Donate
<div class="flexcolumn">
</div>
</div>
</div>
<div class="container">
<div id="leftmain" class="leftmain">
<p id="button" div="leftmain" onclick='show("htpmain")'>📢 How To Play</p>
</div>
<center>
<div id=htpmain class="main">
<div class="toptext">
<h1>
📢 How To Play
</h1>
<p>This guide will get you start the game and will be helpful to grasp everything you need to do.
</p>
</div>
<div class="card" />
</div>
</center>
</div>

Follow-card html css

I made this followers Card design but am having a bit of problem when styling it, when I try to add margin-right to align the image to the right side of the container for some reason it doesn't align to the right, It aligns it more to the left and it stretches the container, it also grabs the text even though they're both in separate containers, same for the button. And for some reason instead of using padding on the follow__content, I instead used gave a width but for some reason the image get left out.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 2rem 10rem;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 2rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="cybercybrog.jpg" alt="">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
Follow
</div>
</div>
</div>
I think this is your desired output.I used the padding property in the follow__content class and changed its' values by giving all the sides padding like this. Since you had given padding only for two sides it was applied incorrectly.
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 10px 100px 10px 10px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 20px 100px 20px 10px;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 0rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="https://www.slashfilm.com/img/gallery/joss-whedon-says-he-cut-cyborgs-justice-league-storyline-because-ray-fisher-is-a-bad-actor/l-intro-1642457019.jpg" alt="Profile Image">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
Follow
</div>
</div>
</div>

I can't change the image in my website to responsive

I'm working on my activity website and I currently have problem with the image in my about section with its responsiveness. I'm trying to change my image where when I minimize the browser, the image will also adjust to smaller but I can't find way to adjust it and make it responsive. Kindly help me.
#abouts {
background: #07414C;
display: inline-block;
width: 100%;
}
.about{
padding: 100px 0px;
background-color: #033541;
}
.about .about-picture img {
width: 430px;
}
.about-text{
width: 550px;
}
.main{
width: 1130px;
max-width: 95%;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-around;
}
.about-text h2{
color: white;
font-size: 75px;
text-transform: capitalize;
margin-bottom: 20px;
}
.about-text h5{
color: white;
letter-spacing: 2px;
font-size: 22px;
margin-bottom: 25px;
text-transform: capitalize;
}
.about-text p{
color: white;
letter-spacing: 1px;
line-height: 28px;
font-size: 18px;
margin-bottom: 45px;
}
#media screen and (max-width: 768px) {
.about .main {
align-items: center;
text-align: center;
display: flex;
flex-direction: column;
}
.about .about-picture img {
max-width: 100%;
height: auto;
}
.about .main .about-text h5 {
width: 100%;
font-size: 18px;
text-align: center;
padding-right: 1.2rem;
padding-left: 1.2rem;
}
.about .main .about-text h2 {
width: 100%;
font-size: 50px;
text-align: center;
padding-right: 1.8rem;
padding-left: 1.8rem;
}
.about .main .about-text p {
width: 100%;
font-size: 15px;
text-align: justify;
padding-right: 2.8rem;
padding-left: 2.8rem;
}
}
<!----about start---->
<div id = "abouts">
<section class="about">
<div class="main">
<div class = "about-picture">
<img src="aboutpic.jpg">
</div>
<div class="about-text">
<h2>About Me</h2>
<h5>word 1<span>, word 2, and word 3</span></h5>
<p>Name, age, place. school where im studying. things that i love. motto.</p>
</div>
</div>
</section>
</div>
The max-width should be defined in pixel, not the simple width.
And it's enough to make it fluid, no need for extra media query code.
.about .about-picture img {
width: 100%;
max-width: 430px;
}

Fine tune a css element :hover area

I have a little tab coming out of a box, and for some reason applying a hover on that tab is very buggy and the actual hovering area is way above it. What is causing that and how can i fix it?
JSFiddle: https://jsfiddle.net/nmr4wu2z/
body {
background-color: #F5F5F5;
font-family: 'Open Sans Condensed', sans-serif;
width: 90%;
margin: 0 auto;
}
.logo {
height: 250px;
width: 250px;
background-color: #FF7148;
margin-top: 5%;
margin-left: 5%;
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 300;
z-index: -1;
box-shadow: 1px 1px 1px black;
}
.contact {
height: 70px;
width: 280px;
position: relative;
background-color: #FF7148;
box-shadow: 1px 1px 1px black;
top: -150%;
z-index: -2;
transition: all 0.5s ease;
}
.contact:hover {
margin-left: 80%;
}
.contactText {
margin-right: -15.5em;
text-align: center;
transform: rotate(90deg);
font-family: 'Open Sans Condensed', sans-serif;
color: white;
padding-top: 40px;
}
.contactEmail {
color: white;
margin-top: -3.4em;
text-align: center;
padding-left: 5px;
}
.logoText {
color: #F5F5F5;
text-align: right;
padding: 170px 10px;
}
<!-- use <header>, <nav>, <article>, <section>, <aside>, and <footer> -->
<header>
<div class="logo">
<h3 class="logoText"> Name <br> &nbsp &nbsp A Blog </h3>
<div class="contact">
<h3 class="contactText"> Contact </h3>
<h3 class="contactEmail"> Example#blabla.com </h3>
</div>
</div>
You have to make some changes
body {
background-color: #f5f5f5;
font-family: "Open Sans Condensed",sans-serif;
margin: 0 auto;
width: 90%;
}
.logo {
background-color: #ff7148;
box-shadow: 1px 1px 1px black;
font-family: "Open Sans Condensed",sans-serif;
font-weight: 300;
height: 250px;
margin-left: 5%;
margin-top: 5%;
position: relative;
width: 250px;
}
.contact {
background-color: #ff7148;
box-shadow: 1px 1px 1px black;
height: 105px;
position: absolute;
top: 30px;
transition: all 0.5s ease 0s;
width: 280px;
cursor: pointer;
}
.contact:hover {
margin-left: 85%;
}
.contactText {
color: white;
font-family: "Open Sans Condensed",sans-serif;
/* margin-right: -15.5em; */
/* padding-top: 40px; */
text-align: center;
transform: rotate(90deg);
transform-origin: 192px 85px 0;
}
.contactEmail {
color: white;
margin-top: -1.1em;
padding-left: 5px;
text-align: center;
}
.logoText {
background: #ff7148 none repeat scroll 0 0;
color: #f5f5f5;
padding: 170px 10px 35px;
position: relative;
text-align: right;
z-index: 1;
}
<header>
<div class="logo">
<h3 class="logoText"> Name <br> &nbsp &nbsp A Blog </h3>
<div class="contact">
<h3 class="contactText"> Contact </h3>
<h3 class="contactEmail"> Example#blabla.com </h3>
</div>
</div>
in with your style like I do in below snippet -
While the answer above triggers the hover for .contact, it's still buggy when you hover above the square.
In this jsfiddle I changed the approach a bit. Take .contact out of .logo (as it doesn't make logical sense) and apply float: left to both. Instead of overlaying them and adjusting the margin to make .contact move left, I start with a lower width and overflow: hidden; on contact, and increase the width on hover.

Cross-browser legend centering

I'm getting different results on my legend centering across browsers:
Should be like this:
But instead I get different margins on other browsers:
HTML
<div class="teaser-header">
<fieldset class="teaser-fieldset">
<legend class="teaser-legend">We are a very passionate team</legend>
<h1>Who we are</h1>
</fieldset>
</div>
CSS
.teaser-header {
padding-top: 70px;
}
.teaser-fieldset {
border: 1px solid white;
color: white;
text-align: center;
width: 400px;
margin: auto;
}
.teaser-fieldset h1 {
color: white;
text-align: center;
margin: 0;
padding-bottom: 20px;
font-family: "Montserrat";
}
.teaser-legend {
padding: 0 10px;
width: 80%;
margin-left: auto;
margin-right: auto;
color: white;
font-size: 1em;
text-transform: uppercase;
margin-bottom: 0;
}
Any ideas? Thanks!
Setting the margin-left and margin-right explicitly as 10% seems to fix the centering issue. The 10% value is nothing but half of (100% - width).
.teaser-header {
padding-top: 70px;
}
.teaser-fieldset {
border: 1px solid white;
color: white;
text-align: center;
width: 400px;
margin: auto;
}
.teaser-fieldset h1 {
color: white;
text-align: center;
margin: 0;
padding-bottom: 20px;
font-family: "Montserrat";
}
.teaser-legend {
/* padding: 0 10px; remove this */
width: 80%;
margin-left: 10%; /* change this */
margin-right: 10%; /* change this */
color: white;
font-size: 1em;
text-transform: uppercase;
margin-bottom: 0;
text-align: center; /* add this */
}
body {
background: black;
}
<div class="teaser-header">
<fieldset class="teaser-fieldset">
<legend class="teaser-legend">We are a very passionate team</legend>
<h1>Who we are</h1>
</fieldset>
</div>