I would like to display dummy images in a row next to each other as shown in this:
As I am not so good with CSS I was wondering how to do this in a proper manner? The pictures I have are all statically served, none of this has to be dynamic, or sliding, or anything, just displaying and scaling up responsively
Thank you for your input
Tried around with position absolute and relative, but was weirdly positioned all over the place. I'm using Bootstrap 4 in this project
You can try this:
body {
background: #20262E;
}
div {
margin: 10px;
padding: 10px;
background: #ffffff;
}
img {
width: 24%;
border-radius: 50%;
}
<div>
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="Avatar 1">
<img src="https://www.w3schools.com/howto/img_avatar2.png" alt="Avatar 2">
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="Avatar 3">
<img src="https://www.w3schools.com/howto/img_avatar2.png" alt="Avatar 4">
</div>
And if you want the green tick with image follow this:
body {
background: #20262E;
}
#image-gallery {
margin: 10px;
padding: 10px;
background: #ffffff;
}
.image-box{
display: inline-block;
position: relative;
width: 24%;
}
img {
width: 100%;
border-radius: 50%;
}
.green-tick {
position: absolute;
bottom: 10%;
right: 10%;
border-radius: 50%;
color: #ffffff;
background: #00ff00;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" type="text/css" />
<div id="image-gallery">
<div class="image-box">
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="Avatar 1">
<i class="fa fa-check green-tick"></i>
</div>
<div class="image-box">
<img src="https://www.w3schools.com/howto/img_avatar2.png" alt="Avatar 2">
<i class="fa fa-check green-tick"></i>
</div>
<div class="image-box">
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="Avatar 3">
<i class="fa fa-check green-tick"></i>
</div>
<div class="image-box">
<img src="https://www.w3schools.com/howto/img_avatar2.png" alt="Avatar 4">
<i class="fa fa-check green-tick"></i>
</div>
</div>
Related
I am trying to implement the following header design in Bootstrap.
I tried using the grid system but this does not feel like it should be the way to go. The code I have so far does not place the 2 buttons in the right lower corner in the correct position.
The HTML:
<div class="row">
<div class="col-sm-12 mb-3">
<div class="line"></div>
<div class="row">
<div class="col-sm-3 pt-4 pl-5">
<img src="logo.png" class="logo" />
</div>
<div class="col-sm-5"></div>
<div class="col-sm-4">
<a class="btn btn-primary" href="#" role="button">choice 1</a>
<a class="btn btn-primary" href="#" role="button">choice 2</a>
</div>
</div>
</div>
</div>
The CSS:
.line {
position: relative;
}
.line::after {
content: "";
background-color: #ed1e79;
position: absolute;
width: 100%;
height: 20px;
top: 90px;
left: 0px;
z-index: -1;
}
.btn {
border-radius: 0 !important;
}
The line shouldn't be an element in your markup. It should be a background image or a pseudo-element on an existing container element. You can then use Bootstrap's flex structure and align the two buttons vertically at the end of the column.
.bg-line {
background-image: linear-gradient(180deg,
transparent calc(50% - 6px),
#ff0000 calc(50% - 6px),
#ff0000 calc(50% + 6px),
#ffffff calc(50% + 6px));
}
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css"/>
<div class="bg-line d-flex justify-content-between align-items-end">
<div class="col"><!-- flexes to fill space -->
<img src="https://via.placeholder.com/90" class="logo" />
</div>
<div class="col-auto btn-group"><!-- shrinks to fit content -->
<a class="btn btn-primary btn-sm" href="#" role="button">choice 1</a>
<a class="btn btn-secondary btn-sm" href="#" role="button">choice 2</a>
</div>
</div>
Fiddle demo
using flex - d-flex, align-items - align-items-end and justify-content - justify-content-between it should work.
example in CSS:
header {
margin: 10px;
display: flex;
justify-content: space-between;
border: solid 2px black;
padding: 10px;
align-items: flex-end;
}
.img {
height: 100px;
width: 100px;
border: solid 2px black;
border-radius: 50%;
}
.btns {
height: 20px;
width: 150px;
border: solid 2px black;
}
<header>
<div class="img"></div>
<div class="btns"></div>
</header>
I'm trying to center three div boxes within one large one. A grid is going to be 3 wide and auto height.
.t-box920g {
width: 960px;
height: auto;
background: #121212;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: auto;
border: 1px dotted #363636;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
}
.i-box {
width: 279px;
height: 209px;
background: #ffffff;
margin-right: auto;
margin-left: auto;
float: left;
display: inline;
text-align: justify;
}
.i-pbox {
width: 276px;
height: 206px;
background: #121212;
border: solid 2px #ffffff;
margin-left: auto;
margin-right: auto;
text-align: justify;
}
#i-imageconstrain {
width: auto;
height: auto;
max-width: 276px;
max-height: 206px;
min-width: 276px;
min-height: 206px;
overflow-x: hidden;
overflow-y: hidden;
}
<div class="t-box920g">
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample1.jpg">
<img id="i-imageconstrain" src="images/gallery/sample1.jpg" border="0" />
</a>
</div>
</div>
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample2.jpg">
<img id="i-imageconstrain" src="images/gallery/sample2.jpg" border="0" />
</a>
</div>
</div>
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample3.jpg">
<img id="i-imageconstrain" src="images/gallery/sample3.jpg" border="0" />
</a>
</div>
</div>
</div>
Everything works as planned EXCEPT for the content of t-box920g being left justified. I've tried a lot of combos and none have worked so far. Got a suggestion? I'll let you know if I tried already.
Tried text-align, align-content, align-items, margin: auto in combinations for all css.
I expect it to be center justified with nice even spacing. Actually is all left.
Use flexbox.
You can read more about how to use it here and here if you like to learn through games.
This question was asked and answered on Stack Owerflow already more than once, for instance here.
.t-box920g {
display: flex;
justify-content: space-between;
align-items: center;
}
.t-box920g .i-box {
background-color: blue;
width: 32%;
}
<div class="t-box920g">
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample1.jpg">
<img id="i-imageconstrain" src="images/gallery/sample1.jpg" border="0" />
</a>
</div>
</div>
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample2.jpg">
<img id="i-imageconstrain" src="images/gallery/sample2.jpg" border="0" />
</a>
</div>
</div>
<div class="i-box">
<div class="i-pbox">
<a data-fancybox="gallery" href="images/gallery/sample3.jpg">
<img id="i-imageconstrain" src="images/gallery/sample3.jpg" border="0" />
</a>
</div>
</div>
</div>
This is my total code. There are two div. When I scroll down the page, the 2nd div is overlapping with the 1st one, and it goes below to the 1st div. As you can see in the screenshot, the image and paragraph are over the 1st div.but i want the two div's separate to each other and the 2nd one to properly sit in it's own place. I stack in this portion. Please help me out...thanks in advance
body {
overflow-x: hidden;
}
#particle {
background-color: blue;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 550px;
}
#overlay {
position: relative;
}
#inner-banner-image {
padding-top: 12%;
width: 80%;
margin: auto;
}
#banner-content {
position: relative;
padding-top: 6%;
padding-bottom: 6%;
overflow: hidden;
margin-bottom: 12%;
background-color: rgba(0, 0, 0, 0.7);
max-width: 520px;
margin-top: 5%;
}
#button {
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
padding: 10px 16px;
font-size: 15px;
width: 155px;
border-radius: 6px;
}
.about {
background-color: #C57ED3;
padding-top: 100px;
color: #490D40;
height: 510px;
text-align: center;
}
p {
padding: 50px 50px;
text-align: center;
justify-content: center;
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--jQuery library-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--Latest compiled and minified JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="resume.css" type="text/css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<title>
RESUME</title>
</head>
<body>
<div id="particle"></div>
<div id="overlay">
<div id="inner-banner-image">
<center>
<div id="banner-content">
<marquee bgcolor="#c9302c" behavior="alternate">
<font color="white">WELCOME TO OUR WEBSITE</marquee>
<h1>We sell lifestyle</h1>
<p>Flat 40% OFF on premium brands </p>
<div id="button">
Shop Now
</div>
</div>
</center>
</div>
</div>
<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script src="p.js"></script>
<div class="about">
<div class="row">
<div class="col-12 col-md-4">
<img src="p.jpg" class="img-thumbnail">
</div>
<div class="col-12 col-md-8">
<h3>Main Description</h3>
<p>Roll on the floor purring your whiskers off intrigued by the shower burrow under covers, and play time, rub face on everything, intently sniff hand, or pelt around the house and up and down stairs chasing phantoms. Attack feet. Damn that dog shake
treat bag under the bed drink water out of the faucet for lick butt love to play with owner's hair tie. Swat at dog give attitude.</p>
<div class="m">
<a class="btn" id="download" href="#">
<i class="fas fa-download">Download Resume</i>
</a>
</div>
<div class="middle">
<a class="btn" id="b" href="#">
<i class="fab fa-facebook-f"></i>
</a>
<a class="btn" id="c" href="#">
<i class="fab fa-twitter"></i>
</a>
<a class="btn" id="d" href="#">
<i class="fab fa-linkedin-in"></i>
</a>
</div>
</div>
</div>
</div>
</body>
</html>
If I understood correctly, you want the background of each section to scroll along with the content? Here you go:
body {
overflow-x: hidden;
}
#particle {
position: fixed;
height: 100%;
width: 100%;
}
#overlay {
background-color: blue;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 550px;
}
#inner-banner-image {
padding-top: 70px;
width: 80%;
margin: auto;
}
#banner-content {
padding-top: 6%;
padding-bottom: 6%;
overflow: hidden;
margin-bottom: 12%;
background-color: rgba(0, 0, 0, 0.7);
max-width: 520px;
margin-top: 5%;
}
#button {
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
padding: 10px 16px;
font-size: 15px;
width: 155px;
border-radius: 6px;
}
.about {
background-color: #C57ED3;
padding-top: 100px;
color: #490D40;
height: 510px;
text-align: center;
}
p {
padding: 50px 50px;
text-align: center;
justify-content: center;
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--jQuery library-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--Latest compiled and minified JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="resume.css" type="text/css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<title>
RESUME</title>
</head>
<body>
<div id="particle"></div>
<div id="overlay">
<div id="inner-banner-image">
<center>
<div id="banner-content">
<marquee bgcolor="#c9302c" behavior="alternate">
<font color="white">WELCOME TO OUR WEBSITE</marquee>
<h1>We sell lifestyle</h1>
<p>Flat 40% OFF on premium brands </p>
<div id="button">
Shop Now
</div>
</div>
</center>
</div>
</div>
<div class="about">
<div class="row">
<div class="col-12 col-md-4">
<img src="p.jpg" class="img-thumbnail">
</div>
<div class="col-12 col-md-8">
<h3>Main Description</h3>
<p>Roll on the floor purring your whiskers off intrigued by the shower burrow under covers, and play time, rub face on everything, intently sniff hand, or pelt around the house and up and down stairs chasing phantoms. Attack feet. Damn that dog shake
treat bag under the bed drink water out of the faucet for lick butt love to play with owner's hair tie. Swat at dog give attitude.</p>
<div class="m">
<a class="btn" id="download" href="#">
<i class="fas fa-download">Download Resume</i>
</a>
</div>
<div class="middle">
<a class="btn" id="b" href="#">
<i class="fab fa-facebook-f"></i>
</a>
<a class="btn" id="c" href="#">
<i class="fab fa-twitter"></i>
</a>
<a class="btn" id="d" href="#">
<i class="fab fa-linkedin-in"></i>
</a>
</div>
</div>
</div>
</div>
</body>
</html>
I removed the particle code since it's irrelevant to the question.
Why does the latest Firefox browser render Bootstrap thumbnails differently than Google Chrome? I stuck with getting all thumbnails equal height but can't figure out how.
Setting the max-width attribute to none fixes the height, but lets the image overflow its parent container. Can you tell me why and how to fix so that it appears in all Browsers like it appears in Google Chrome?
Here is my fiddle.
EDIT: added screenshots (right-click -> 'open in new tab' to see fullsize)
Chrome: max-width = 100% (default) - fitting nicely
Chrome: max-width = none - overflowing parent
Firefox: max-width = 100% (default) - downscaled by BS
Firefox: max-width = none - overflowing parent
If your images height is fixed to 240px, than one of the solutions is to wrap them in absolute positioned span and use this css:
.thumbnails {
margin: 0 0 10px 0;
padding: 0;
}
.thumbnail {
position: relative;
height: 250px;
}
.thumbnail span {
margin: 0 auto;
display: block;
position: absolute;
top: 4px;
left: 4px;
right: 4px;
bottom: 4px;
overflow: hidden;
}
.thumbnail span img {
margin: 0 auto;
display: block;
}
Check it in this Fiddle, or run the snippet below:
.thumbnails {
margin: 0 0 10px 0;
padding: 0;
}
.thumbnail {
position: relative;
height: 250px;
}
.thumbnail span {
margin: 0 auto;
display: block;
position: absolute;
top: 4px;
left: 4px;
right: 4px;
bottom: 4px;
overflow: hidden;
}
.thumbnail span img {
margin: 0 auto;
display: block;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="panel panel-default">
<div class="panel-body">
<div id="slideshow">
<div>
<div>
<div data-index="1">
<ul class="thumbnails list-unstyled">
<li class="slide col-xs-4">
<a href="#" class="thumbnail" title="This is ok">
<span>
<img src="http://i.imgur.com/DONm5Ih.jpg" class="shot landscape" width="auto" height="auto" alt="image" />
</span>
</a>
</li>
<li class="slide col-xs-4">
<a href="#" class="thumbnail" title="This is ok">
<span>
<img src="http://i.imgur.com/TFEAQTJ.jpg" class="shot portrait" width="auto" height="auto" alt="image" />
</span>
</a>
</li>
<li class="slide col-xs-4">
<a href="#" class="thumbnail" title="This is ok">
<span>
<img src="http://i.imgur.com/WZbs0wI.jpg" class="shot landscape" width="auto" height="auto" alt="image" />
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
.page {
background: none;
width: 1000px;
margin: 0 auto;
text-align: left;
padding: 0px 0px 0px 0px;
}
.header-container {
background-image: url("http://patolino.com/img/fundo-top.jpg");
width: 100%;
height: 133px;
}
.header{
padding:0px 0px 0px 0px;
width: 1000px;
position: fixed;
}
.header .logo { float:left;
margin-top:15px;
width: 30%;
}
.header h1.logo {
float:left;
width: 30%;
padding: 0;
}
.nav-container {background: url(http://www.patolino.com/img/bg-menu.jpg) repeat;
width: 1000px;
height: 43px;
left: 0;
padding: 0px 0px 0px 0px;
}
.header .welcome-msg {
}
.header .form-search {
top-margin: 15px;
}
.header .links {
}
div.slidercontrolwr {
top: 30px;
}
.quick-access{
height: 133px;
}
http://imageshack.us/photo/my-images/46/screenshot20130209at818.png/
http://img145.imageshack.us/img145/3022/screenshot20130209at817.png
But basically:
<div class="page">
<div class="header-container">
<div class="header">
<h1 class="logo"><strong>Carol Baby</strong><img src="http://carolbaby.com.br/skin/frontend/base/default/logo.png" alt="Carol Baby"></h1>
<div class="quick-access">
<p class="welcome-msg">Seja bem vindo! </p>
<form id="search_mini_form" action="http://carolbaby.com.br/catalogsearch/result/" method="get">
<div class="form-search">
<label for="search">Buscar:</label>
<input id="search" type="text" name="q" value="" class="input-text" autocomplete="off">
<button type="submit" title="Buscar" class="button"><span><span>Buscar</span></span></button>
<div id="search_autocomplete" class="search-autocomplete" style="display: none;"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Procure na loja inteira aqui...');
searchForm.initAutocomplete('http://carolbaby.com.br/catalogsearch/ajax/suggest/', 'search_autocomplete');
//]]>
</script>
</div>
</form>
<ul class="links">
<li class="first">Minha Conta</li>
<li>Minha Lista de Desejos</li>
<li>Meu Carrinho</li>
<li>Fechar Compra</li>
<li class=" last">Entrar</li>
</ul>
</div>
</div>
</div>
<div class="nav-container">
<ul id="nav">
<li class="level0 nav-1 level-top first">
<a href="http://carolbaby.com.br/bercos.html" class="level-top">
<span>Berços</span>
</a>
</li><li class="level0 nav-2 level-top">
<a href="http://carolbaby.com.br/roupeiros.html" class="level-top">
<span>Roupeiros</span>
</a>
</li><li class="level0 nav-3 level-top">
<a href="http://carolbaby.com.br/comodas.html" class="level-top">
<span>Cômodas</span>
</a>
</li><li class="level0 nav-4 level-top">
<a href="http://carolbaby.com.br/linhas-completas.html" class="level-top">
<span>Dormitórios Completos</span>
</a>
</li><li class="level0 nav-5 level-top last">
<a href="http://carolbaby.com.br/kits-para-bercos.html" class="level-top">
<span>Kits para Berços</span>
</a>
</li> </ul>
</div>
What I need:
Extend the background fundo-top.jpg and extend bg-menu.jpg to the white sides (left and right) that shows up in sample image [2] borders
I solved it with CSS, working with positions relative and absolute, besides pay attention on divs and sub divs coding.