I have made a website where the homepage looks like the this :
I want to move the ficstore logo in the middle and split the bar into two halves and put one on either side , like this :
I've split my bar image into two different parts for each side and tried to put the images in different columns. But it just doesn't seem to work.
This is the snippet for the current code :
<div class="container">
<div class="row">
<div class="col-xs-8">
<h2 style="font-family:helvetica;"><span>Home Page</span></h2>
</div>
<div class="col-xs-4">
<img src="http://lorempixel.com/400/200/" class="img-responsive right" style="width:400px; z-index:1;" />
</div>
<img src="http://lorempixel.com/400/200/" class="img-responsive right" style="position: absolute; margin-top: 135px; z-index: -2;" />
</div>
<hr class="style18" />
Can someone help?
I've tried the following code as well :
<div class="container">
<div class="row">
<div class="col-xs-8">
<h2 style="font-family:helvetica;"><span>Book Info</span></h2>
</div>
<div class="flex-row">
<div>
<img src="http://lorempixel.com/400/200/" class="img-responsive right" style="width:400px; z-index:1;" />
</div>
<div>
<img src="http://lorempixel.com/400/100/" class="img-responsive right" style="position: absolute; margin-top: 135px; z-index: -2;" />
</div>
<div>
<img src="http://lorempixel.com/400/100/" class="img-responsive right" style="position: absolute; margin-top: 135px; z-index: -2;" />
</div>
</div>
</div>
<hr class="style18" />
Css :
.flex-row {
display: flex;
align-items: center;
justify-content: center;
}
This is a great time to use flex:
HTML:
<div class='flex-row'>
<div><img src="left.png"></div>
<div><img src="center.png"></div>
<div><img src="right.png"></div>
</div>
CSS:
.flex-row {
display: flex;
align-items: center;
justify-content: center;
}
This is one way to do it. I would encourage you to ditch whatever framework you are using. col-x-whatever is bad news bears.
Here's a fiddle too - with an inline-block way.
https://jsfiddle.net/sheriffderek/fcwyg0zb/
inline-block
.images {
text-align: center;
}
.images .image-w {
display: inline-block;
vertical-align: middle;
}
flexbox
.image-w img {
display: block;
width: 100%;
height: auto;
}
.one {
max-width: 200px;
}
.two {
max-width: 400px;
margin: 0 1rem;
}
.three {
max-width: 200px;
}
.images {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
<section class='images'>
<div class='image-w one'>
<img src='https://placehold.it/300x150' alt='left'>
</div>
<div class='image-w two'>
<img src='https://placehold.it/600x300' alt='center'>
</div>
<div class='image-w three'>
<img src='https://placehold.it/300x150' alt='right'>
</div>
</section>
I suggest you have to have 3 images. The bar should divided in two. Put the Fictore in the middle then add display:block.
Related
How can I align my icons left-horizontally and center-vertically without moving my text? For example:
Here is my code:
.leftpanel a {
display: block;
height: 65px;
text-align: center;
/* This also move my icons which I don't want to */
vertical-align: middle;
line-height: 65px;
}
<div class="leftpanel">
<img src="media/logo.png" class="logo">
<img src="media/icons/home.png" class="icons">acceuil
<img src="media/icons/sofa.png" class="icons">le grand salon
<img src="media/icons/shop.png" class="icons">boutique
</div>
You should wrap the text with an element that takes all available space, and also has text-align: center.
.menu a {
display: flex;
align-items: center;
}
.menu a span {
flex: 1;
text-align: center;
}
<div class="leftpanel">
<img src="media/logo.png" class="logo">
<div class="menu">
<a href="acceuil" class="acceuil">
<img src="media/icons/home.png" class="icons">
<span>acceuil</span>
</a>
<a href="le-grand-salon" class="le-grand-salon">
<img src="media/icons/sofa.png" class="icons">
<span>le grand salon</span>
</a>
<a href="boutique" class="boutique">
<img src="media/icons/shop.png" class="icons">
<span>boutique</span>
</a>
</div>
</div>
You can use flexbox to do it. Flexbox solves a lot of problems in general and I suggest you use it for layouts like this.
.leftpanel a {
display: flex;
height: 65px;
align-items: center;
line-height: 65px;
}
.leftpanel a img {
display: block;
flex-grow: 0;
}
.leftpanel a span {
display: block;
flex-grow: 1;
text-align: center;
}
<!-- I put the text in spans so we can style it separately -->
<div class="leftpanel">
<img src="media/logo.png" class="logo">
<img src="media/icons/home.png" class="icons"><span>acceuil</span>
<img src="media/icons/sofa.png" class="icons"><span>le grand salon</span>
<img src="media/icons/shop.png" class="icons"><span>boutique</span>
</div>
This question already has answers here:
Centering in CSS Grid
(9 answers)
Closed 1 year ago.
I am making my first html/css website and I have the start of a skeleton with placeholder images and icons. I want the icons with text, to each be centered within their respective column. I'm using a CSS grid to set up the columns.
.content-items-wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.content-item-wrapper {
position: relative;
}
.content-img-background {
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.img-text-wrapper {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
padding-left: 100px;
padding-right: 100px;
}
<div class="master-content-wrapper">
<div class="content-items-wrapper">
<div class="content-item-wrapper">
<div class="content-img-background" style="background-image: URL(images/blue-placeholder.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/wrench-placeholder.png">
</div>
<div class="subtitle">
Services
</div>
</div>
</div>
<div class="content-item-wrapper">
<div class="content-img-background" style="background-image:URL(images/white-placeholder.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/computer-placeholder.png">
</div>
<div class="subtitle">
Technicians
</div>
</div>
</div>
<div class="content-item-wrapper">
<div class="content-img-background" style="background-image:URL(images/red-placeholder.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/paper-placeholder.png">
</div>
<div class="subtitle">
Reviews
</div>
</div>
</div>
</div>
I tried different paddings and tweaking some other things but it never gets exactly in the center of the three vertical columns. The icon with text I'm referring to is the ".img-text-wrapper" div.
If we put some background color and border to some of the elements we can more clearly see what is going on:
The absolutely positioned elements' contents are centered within themselves but not within their parent elements. To achieve that we need to display the parents as flex with justification and alignment centered. Also, the div giving the background to each of these elements does not seem to have any particular meaning other than providing a background image so that is removed and the background is put on the parent in this snippet which gives this result (on wide screens see note):
.content-items-wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.content-item-wrapper {
position: relative;
border-style: solid;
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-color: pink;
display: flex;
justify-content: center;
align-items: center;
}
.content-img-background {
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-color: pink;
}
.img-text-wrapper {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
padding-left: 100px;
padding-right: 100px;
background-color: lime;
}
<div class="master-content-wrapper">
<div class="content-items-wrapper">
<div class="content-item-wrapper" style="background-image: URL(images/blue-placeholder.jpg)">
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://i.stack.imgur.com/Iynpe.jpg">
</div>
<div class="subtitle">
Services
</div>
</div>
</div>
<div class="content-item-wrapper" style="background-image:URL(images/white-placeholder.jpg)">
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://i.stack.imgur.com/Iynpe.jpg">
</div>
<div class="subtitle">
Technicians
</div>
</div>
</div>
<div class="content-item-wrapper" style="background-image:URL(images/red-placeholder.jpg)">
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://i.stack.imgur.com/Iynpe.jpg">
</div>
<div class="subtitle">
Reviews
</div>
</div>
</div>
</div>
(Note that on smaller displays the cells shrink to fit - this needs correction for full responsiveness - the square can't be given a fixed px dimension)
Sorry i removed a lot of the css as this is not necessary for the answer.
.content-img-background {
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.column {
float: left;
width: 30%;
}
div {
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="column">
<div style= "background-image: URL(images/blue-placeholder.jpg)">
<img src="images/wrench-placeholder.png">
</div>
<div class="subtitle">
Services
</div>
</div>
<div class="column">
<div style= "background-image:URL(images/white-placeholder.jpg)">
<img src="images/computer-placeholder.png">
</div>
<div class="subtitle">
Technicians
</div>
</div>
<div class="column">
<div style= "background-image:URL(images/red-placeholder.jpg)">
<img src="images/paper-placeholder.png">
</div>
<div class="subtitle">
Reviews
</div>
</div>
</div>
</div>
</body>
</html>
I try to develop website for my portfolio. I want to do something like that :
But I've some problem with the 3 icons for Twitter/Instagram and Deviantart. To put the icons like that, I use the flexbox in html. Currently, I've that :
#conteneur {
display: flex;
justify-content: space-between;
}
<div id="conteneur">
<div class="element1">
<img src="https://zupimages.net/up/21/29/vbxh.png">
</div>
<div class="element2">
<img src="https://zupimages.net/up/19/51/4gl0.png">
</div>
<div class="element3">
<img src="https://zupimages.net/up/21/29/dbtc.png">
</div>
</div>
Test with CodePen here : https://codepen.io/lucbenedet/pen/yLbPMgK
But as you can see, the pictures are too large and when I try to put the pictures to a size of 35px like that :
#conteneur
{
display: flex;
justify-content: space-between;
width: 35px;
}
or
.element1
{
width: 35px;
}
The resize doesn't works...
Someone to show how to do that ?
You can update your CSS with following code.
#conteneur {
display: flex;
justify-content: space-between;
width: 150px;
padding: 10px;
}
#conteneur div img {
width: 35px;
height: 35px;
}
<div id="conteneur">
<div class="element1">
<img src="https://zupimages.net/up/21/29/vbxh.png">
</div>
<div class="element2">
<img src="https://zupimages.net/up/19/51/4gl0.png">
</div>
<div class="element3">
<img src="https://zupimages.net/up/21/29/dbtc.png">
</div>
</div>
You can have some space between icons when you maximize the width of the container
you can reset width on the flex-container to max-content (3 icones shouldnot overflow) and use gap to set a distance in between them.
You could use em for the gap and icon's width to have a coherent render.
Possible example:
#conteneur {
display: flex;
width: max-content;
align-items: center;
margin: auto;
gap: 1.6em;
}
#conteneur div img {
width: 3em;
}
<div id="conteneur">
<div class="element1">
<img src="https://zupimages.net/up/21/29/vbxh.png">
</div>
<div class="element2">
<img src="https://zupimages.net/up/19/51/4gl0.png">
</div>
<div class="element3">
<img src="https://zupimages.net/up/21/29/dbtc.png">
</div>
</div>
possible example from your codepen https://codepen.io/gc-nomade/pen/qBmVjBV
First things first, a fiddle: https://jsfiddle.net/2v1axtkz/3/
I have a flex grow box with a floating right image and am trying to add underneath a text box and contain them both within the parent box.
Reason for this is that there is an onclick event for the parent box, so I need both the image box and the text box contained within the same parent.
Right now it's not happening and I can't figure out why.
The markup is:
<div class="sections__container__outside" onclick="action();">
<div class="sections__container__box">
<img src="https://via.placeholder.com/150" class="image">
</div>
<div class="sections__container__box__title">Title</div>
</div>
As you can see from the image, the text is somehow outside the parent container even though it's inside of the div:
How do I fix this?
You have height: 100% on the .sections__container__box. That essentially pushes out the title container. I'm assuming you want the red in the background, so just removing that won't work.
You need to remove the float from the image and make that .sections__container__box display flex and then use the justify-content property to position the image.
.sections__container {
margin: 0 auto;
max-width: 630px;
display: flex;
flex-wrap: wrap;
align-content: stretch;
justify-content: space-between;
}
.sections__container__box {
background-color: #FF0030;
flex: 1 0 100%;
text-align: center;
width: 100% !important;
text-align: right;
display: flex;
justify-content: flex-end;
}
.sections__container__outside {
width: 40%;
flex-grow: 1;
margin: 10px;
}
.image {
display: block;
}
.sections__container__box__title {
margin-bottom: 20px;
}
<div class="sections__container">
<div class="sections__container__outside" onclick="action();">
<div class="sections__container__box">
<img src="https://via.placeholder.com/150" class="image">
</div>
<div class="sections__container__box__title">Title</div>
</div>
<div class="sections__container__outside" onclick="action();">
<div class="sections__container__box">
<img src="https://via.placeholder.com/150" class="image">
</div>
<div class="sections__container__box__title">Title</div>
</div>
<div class="sections__container__outside" onclick="action();">
<div class="sections__container__box">
<img src="https://via.placeholder.com/150" class="image">
</div>
<div class="sections__container__box__title">Title</div>
</div>
<div class="sections__container__outside" onclick="action();">
<div class="sections__container__box">
<img src="https://via.placeholder.com/150" class="image">
</div>
<div class="sections__container__box__title">Title</div>
</div>
</div>
So I am trying to create a flexbox that has several divs inside of it. The divs have an image and a button that should stack but then I would like them to align in a row. I cannot seem to get them to actually go into a row instead they are stacking. Here is the HTML and CSS:
.block2 {
display: flex;
flex-direction: row;
}
.tan {
background: #FFEFD5
}
.kite1 img {
height: 150px;
width: 130px;
padding: 30px;
}
.kite1button img {
height: 50px;
width: 125px;
}
.kite2 img {
height: 150px;
width: 130px;
padding: 30px;
}
.kite2button img {
height: 50px;
width: 125px;
}
<div class="block2 tan">
<div class="kite1">
<img src="kite1.png" />
<div class="kite1button">
<img src="deltasbutton.png" />
</div>
</div>
<div class="kite2">
<img src="diamond-kite.png" />
<div class="kite2button">
<img src="diamondsbutton.png" />
</div>
</div>
<div class="kite3">
<img src="specialty-kite.png" />
<div class="kite3button">
<img src="specialty-button.png" />
</div>
</div>
</div>
Change kite1, kite2, and kite3, to kite.
Then style the kite class like so:
.kite {
display: flex;
flex-direction: column;
}
P.S. If you're going to be using an identifier (i.e. class= or id= or data-whatever=, etc) once, use id. If you plan on using an identifier on multiple elements, always use class. ids can only be used on one element, whereas class can be used on an indefinite number of elements.
.block2 {
display: flex;
}
.kite {
display: flex;
flex-direction: column;
}
<div class="block2 tan" >
<div class="kite">
<img src="kite1.png" />
<div class="kite1button">
<img src="deltasbutton.png"/>
</div>
</div>
<div class="kite">
<img src="diamond-kite.png"/>
<div class="kite2button" >
<img src="diamondsbutton.png"/>
</div>
</div>
<div class="kite">
<img src="specialty-kite.png"/>
<div class="kite3button">
<img src="specialty-button.png"/>
</div>
</div>
</div>