Possitioning an image next to two different text elements - html

I am trying to make a header bar on my HTML page that has a h1 and h2 element but then I want an image to appear to the right of both of them.
What ever i try the image appears below the other two, i have tried display:inline-block; but that didn't seem to work.
Any ideas how i do it?
.headerBar {}
.headerBar h1 {
float: left;
width: 400px;
line-height: 0;
}
.headerBar h2 {
width: 400px;
line-height: 1;
}
.headerBar img {
width: 40px;
border-radius: 50px;
}
<div class="headerBar">
<h1>My Name</h1>
<h2>Welcome</h2>
<img src="https://dummyimage.com/300x200/000000/fff" alt="Photo" />
<br>
</div>

You can wrap your headings in wrapper and make .headerBar flex, for more details see CSS part of Code Snippet.
.headerBar {
display: flex; /* make main container flex */
flex-direction: row; /* this will make container in one row */
align-items: flex-start; /* vertical align content to top */
justify-content: space-between; /* add gap between content */
}
.headerBar h1 {
line-height: 0;
}
.headerBar h2 {
line-height: 1;
}
.headerBar img {
width: 40px;
border-radius: 50px;
}
<div class="headerBar">
<div class="headerWrapper">
<h1>My Name</h1>
<h2>Welcome</h2>
</div>
<img src="https://dummyimage.com/300x200/000000/fff" alt="Photo" />
</div>

Flex is a good solution. You also can grid for that. Is it what you want?
.headerBar {
display: grid;
grid-template-columns: auto auto;
width: 100%;
}
.headerBar h1 {
line-height: 0;
}
.headerBar h2 {
line-height: 1;
}
.headerBar .image {
border-radius: 50px;
grid-row: 1 / 3;
grid-column: 2 / 3;
}
<div class="headerBar">
<h1>My Name</h1>
<div class="image"><img src="https://dummyimage.com/300x200/000000/fff" alt="Photo" /></div>
<h2>Welcome</h2>
</div>

Related

Why are my child divs not expanding the parent, even using display: inline-block?

I have what seems to be a fairly common problem with my CSS, however - I've been searching Stack and others with no answer in sight. Essentially, my container div is not expanding with it's children. I do have Bootstrap 4 installed, however it's use is very limited.
The problem is, all of the CSS is basic. It's a Flexbox three column layout, with a header and footer, inside a container:
<div class="ui-login" *ngIf="showLoginWindow">
<div class="header">
<img src="./../../assets/Logo.png" class="gameLogo">
</div>
<div class="h-body">
<nav class="h-col">…</nav>
<main class="h-content">…</main>
<aside class="h-col">…</aside>
</div>
<div class="footer">
<div class="about">
<b>About Text</b> <br>
About Test LLC - 2020
</div>
</div>
</div>
The layout is basic, as is the CSS itself:
.ui-login {
display: inline-block;
z-index: 200;
border: #34495e solid 2px;
background: #FFF;
.h-body {
display: flex;
flex: 1;
}
/* Style the header */
.header {
flex: 0 0 100%;
text-align: center;
font-size: 35px;
}
.h-content {
flex: 1;
}
.h-col {
/* 12em is the width of the columns */
flex: 0 0 12em;
background: #34495e;
}
/* Style the footer */
.footer {
padding: 10px;
text-align: center;
}
.h-body :nth-child(1) { order: 1; }
.h-body :nth-child(2) { order: 2; }
.h-body :nth-child(3) { order: 3; }
}
There is no applied width, height, padding, or margin, and the parent ui-login is also a display: inline-block. None of this seems to be fixing the overflow, when I need the parent to fully contain the layout children. What am I doing wrong?
.ui-login {
display: inline-block;
z-index: 200;
border: #34495e solid 2px;
background: #FFF;
.h-body {
display: flex;
flex: 1;
}
/* Style the header */
.header {
flex: 0 0 100%;
text-align: center;
font-size: 35px;
}
.h-content {
flex: 1;
}
.h-col {
/* 12em is the width of the columns */
flex: 0 0 12em;
background: #34495e;
}
/* Style the footer */
.footer {
padding: 10px;
text-align: center;
}
.h-body :nth-child(1) { order: 1; }
.h-body :nth-child(2) { order: 2; }
.h-body :nth-child(3) { order: 3; }
}
<div class="ui-login" *ngIf="showLoginWindow">
<div class="header">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExIWFhUXFRsaGBYYFxUYFRkYGRgaGhYXFhcaHSggHRolHRgXITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGzcmICY3Lys3LTcyMDE1NzYrLS0yNywwLS0xMi0vNy8rMDcrMi0tLS01MDA3Ky0tLy0tKy0vLf/AABEIAJ0BQQMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAABAAIDBQYEBwj/xABFEAACAQMDAQUGAwQHBgYDAAABAgMAESEEEjE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bI2n4MB8L1lER5XAAaSRjYDLOxPkPM19O6dQQwIuCLEHgjPNccfSYIWLRQRRsRkpGik/MqM0BnewnYtdJGJHUNqGHibB2X/o09LeZHJ+FhWxSQAWPIo6f3a55eTQDzEealaUEWB5p44+lckXI+dAPRCDc8U+RtwsKfP7p/786h03P0oB0Xh5xelKN3GaOq8qOl4NAKNgoseajeMk3HFDUe9XRD7ooBolAxeoViIyRxTH5Pzrsk4PyoCN5ARYc0yNdpueKZB7wqfU8fWgGyndxmlEdvOKbpeTR1XlQAkXcbjino4AseaOm4+tQT+8f+/KgOjvl9f1pVyUqA/9k=" class="gameLogo">
</div>
<div class="h-body">
<nav class="h-col">…</nav>
<main class="h-content">…</main>
<aside class="h-col">…</aside>
</div>
<div class="footer">
<div class="about">
<b>About Text</b> <br>
About Test LLC - 2020
</div>
</div>
</div>

(HTML CSS) trying to make certain div responsive

I made 2 divs inside container div, and I gave them the element inline block, I wanted them to be side by side. like 1 > 2, not on top of each other.
they look great in my screen size (24inch)
but once the screen size is going down, instead of getting smaller the divs will lay on top of each other
could you help me making them responsive?
html
<div class="exampleboxcontainermainpage">
<div class="exampleboxmainpage">
<h1>create social media Buttons with html and css</h1>
<br>
<div class="socialmediacontainer">
</div>
<br />
<br />
<br />
<br />
<br />
<br>
</div>
<div class="exampleboxmainpage2">
<div class="exampleinsideboxmainpage">
<pre class="prettyprint default">
<!-- Start of showing code -->
<xmp>
<div class="socialmediacontainer">
</div>
</xmp>
<!-- !!!!! End of showing Code !!!!!-->
</pre>
</div>
<button onclick="window.location.href = 'tryyourselfcodes/howto_howto_social_button.php'; " style="left:30px;" class="buttontest">
Try yourself >>
</button>
</div>
</div>
css
.exampleboxcontainermainpage{
padding-left:100px;
}
.exampleboxmainpage {
background-color: #f3f4fa;
border-style: unset;
/* padding: 23px; */
text-align: center;
width: 800px;
height: 400px;
position:relative;
display: inline-block;
bottom:24px;
}
.exampleboxmainpage2 {
background-color: #f3f4fa;
border-style: unset;
padding: 31px;
text-align: center;
width: 900px;
height: 400px;
position:relative;
display: inline-block;
}
.exampleboxmainpage h3 {
padding-bottom: 10px;
display: inline-block;
}
.examplebox button {
display: inline-block;
text-align: center;
}
.exampleinsideboxmainpage {
background-color: black;
text-align: center;
width: 700px;
display: inline-block;
border-style: unset;
}
.exampleinsideboxmainpage p {
font-family: "Roboto", sans-serif;
font-size: 20px;
color: white;
overflow-wrap: break-word;
display: inline-block;
}
Welcome to SO!
Try to use flex as its responsive and easy to use
And on break-screen(below 767px mobile) i just change its direction to
column from row
* {
box-sizing: border-box;
}
.container {
display: flex;
width: 100%;
flex-flow: row wrap;
}
[class*="box--"] {
display: flex;
margin: .25rem;
height: 2rem;
padding: .25rem;
color: white;
}
.box--half {
background: blue;
flex: 1 1 30%;
}
#media all and (max-width: 767px) {
.container{
flex-direction: column;
}
}
<div class="container">
<div class="box--half">1</div>
<div class="box--half">2</div>
</div>
Read more about flex here
If you resist to use inline display instead advanced one like flex or grid you can use media queries to show your div under each other in smaller screen, for example I use 800px for breakpoint. You can use display: block:
.container>div {
display: inline-block;
width: 200px;
height: 200px;
background: gray;
text-align: center;
line-height: 200px;
}
#media all and (max-width: 800px) {
.container>div {
display: block
}
}
<div class="container">
<div>Content 1</div>
<div>Content 2</div>
</div>

HTML/CSS div alignment

When resized, I need the div order changed to move two logos next to each other at 50% width each and the third div (title) 100% width below. Can anyone please direct me with where I am going wrong.
.logo1 {
width: 50%;
float: left;
top: 0px;
}
.logo2 {
width: 50%;
float: right;
top: 0px;
}
.title {
width: 100%;
clear: both;
}
<header>
<div class="logo1">
<img src="Pictures/logo.png" width="189" height="61" border="0">
</div>
<div class="title">
<h1 class="map_title">Infrastructure Web Map</h1>
</div>
<div class="logo2">
<img src="Pictures/Picture1.png" width="310" height="70" border="0">
</div>
</header>
You can do it with the Flexbox:
body {margin: 0}
h1 {
text-align: center;
}
header {
display: flex; /* displays flex-items (children) inline */
flex-wrap: wrap; /* enables their wrapping */
}
header > div {
flex: 1; /* each takes 33.33% of the parent's width */
display: flex; /* addition */
justify-content: center; /* addition */
}
img {
display: block; /* removes bottom margin/whitespace */
width: 100%; /* responsiveness */
}
#media (max-width: 568px) {
header > div {
flex: 0 1 50%; /* flex-grow = default, flex-shrink = default, flex-basis = 50% (initial width) */
}
.title {
flex: 1; /* stretches to fill the parent's width (100%) */
order: 1; /* changes the order, i.e. puts it below/after the #logo2 (by default its "order: 0") */
}
}
<header>
<div class="logo1">
<img src="http://placehold.it/300x200" alt="logo1">
</div>
<div class="title">
<h1 class="map_title">Infrastructure Web Map</h1>
</div>
<div class="logo2">
<img src="http://placehold.it/300x200" alt="logo2">
</div>
</header>
Thanks to all for the help, after some further research and a combination of all the suggestions, this is what I used to get it working:
header {
background-color: #cccccc;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
img {
margin: auto;
display: block;
}
.logo1, .logo2 {
width: 50%;
flex: 1 1 0;
}
.title {
color: #336699;
flex: 100%;
order: 3;
text-align: center;
}
}

How to position this flexbox child depending on presence of another child?

I have a quick follow up to my earlier question posted here.
I'm trying to position a flexbox child element depending on whether another child is present or not.
Best visualised in this codepen
In some panels, ICON3 will not be loaded. The container receives a class of hidden and I can choose to hide it with display or opacity etc.
I'd like ICON4 to stay on the right, and to move up in line with ICON2, and for the wrapper to resize accordingly. But I can't seem to get it working.
What I've tried:
opacity: 0 - this keeps ICON4 on the right, but does not resize the wrapper, as ICON3 still exists and takes up space.
display: none - this just moves ICON4 to when ICON3 was.
Also tried styling combinations using .hidden + .four but I can't find a working solution.
Would appreciate any help!
Snippet below:
* {
font-family: sans-serif;
}
.wrapper {
display: flex;
align-items: flex-start;
width: 500px;
background-color: #F9F9F9;
padding: 10px;
position: relative;
margin-bottom: 2em;
}
.image {
width: 150px;
margin-right: 1em;
}
.row {
display: flex;
flex-direction: column;
flex: 1 0 0;
}
.more {
font-weight: bold;
margin-top: 1em;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 4em;
justify-content: space-around;
}
.hidden {
opacity: 0;
/*display: none; // this pushes ICON4 underneath */
}
.hidden + .four {
/*margin-bottom: 1.4em; // this seems to position .four correctly, but doesn't alter height of .wrapper */
}
.four {
margin-top: auto;
}
.ideal {
position: absolute;
bottom: 20px;
right: -44px;
}
.ideal span {
color: green;
font-weight: bold;
opacity: .2;
margin-right: 4em
}
.ideal {
position: absolute;
bottom: 32px;
right: -201px;
}
.ideal span {
color: green;
font-weight: bold;
opacity: .2;
margin-right: 4em
}
<div class="wrapper">
<div class="image">
<img src="http://placehold.it/150x68" alt="" />
</div>
<div class="row">
<span>Text content</span>
<span>Text content</span>
<span>Text content</span>
<div class="more">
<span class="one">ICON1
</span>
<span class="two">ICON2</span>
<span class="three hidden">ICON3</span>
<span class="four">ICON4</span>
</div>
</div>
<div class="ideal"><span>ICON4</span>< ideal position and wrapper to resize</div>
</div>
I overlooked the height rule on .more
I don't think I change this with css as it's a parent, but with javascript I can add a class to .more and override the height.

Prevent flexbox items from overflowing into siblings

I am trying to make a one-pager site, which is working quite well. I have three sections that need to be fullscreen, that works. But when I resize the window to 500px width and make the height also shorter, the title from the second page comes up on the first page. Same thing happens with the title on the third page, this one displays on the second page.
Here is the codepen: http://codepen.io/anon/pen/jWaxMK
HTML:
<section>
<h2>Title 1</h2>
<div class="box">
</div>
<div class="box">
</div>
</section>
<section>
<h2 class="blue">Title 2</h2>
<div class="box circle"></div>
<div class="box circle"></div>
<div class="box circle"></div>
</section>
<section>
<h2 class="white">Title 3</h2>
</section>
CSS:
html,
body,main {
height: 100%;
margin: 0;
padding: 0;
}
section {
position: relative;
width: 100%;
height: 100%;
color: #ececec;
text-align: center;
display: flex; /* default: row nowrap */
flex-flow:row wrap;
justify-content: center;
align-items: center;
align-content: center;
}
section:nth-child(1) {
background: #06a2cb;
}
section:nth-child(2) {
background: #ececec;
}
section:nth-child(3) {
background: #F5E5D8;
}
h2{
margin-top:0;
font-family: 'Lobster';
margin: 1em;
flex: 0 0 100%;
color: black;
}
.box{
width: 250px;
height: 250px;
display: inline-block;
background-color: #ececec;
border-radius: 10px;
flex: 0 0 250px;
}
.circle{
border-radius: 50%;
background-color: white;
}
Any help is appreciated, thanks!
You can solve the problem by making all the section elements flex items, and giving them a minimum height.
Add this to your CSS:
body {
display: flex;
flex-direction: column;
}
section {
min-height: 100%; /* alternatively, try `min-height: 100vh` */
flex-shrink: 0;
}
Revised Codepen