Sorry if I posted something similar to other questions, but actually I needed solution. Well what I am trying to do is am creating gallery of images. So I have images of 200px, each image is block. So in order to center those image according to screen-sizes I am trying to wrap those images inside other div(i.e. inline-block). But its not ready to move in center.
I also want to mention that I am using this within a container.
.gallery{
display:inline-block; /* I am not sure what to do here */
}
.thumbnail{
width:200px;
height:200px;
border:1px solid #aaa;
border-radius:5px;
display:block;
}
.thumbnail img{
width:100%;
height:100%;
border:5px solid white;
border-radius:5px;
}
.gallery-item{
float:left;
margin:10px;
}
.clearfix:after{
clear:both;
}
.clearfix:after, .clearfix:before{
display:table;
content: " ";
}
.clearfix:after{
content:" ";
height:10px;
}
<div class="gallery">
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallary-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<span class="clearfix"></span>
</div>
Don't use float property if you want elements to be centered.
.gallery {
font-size: 0; /*fix for white space */
text-align: center;
}
.thumbnail {
display: inline-block;
margin: 10px;
width: 200px;
height: 200px;
border: 1px solid #aaa;
border-radius: 5px;
box-sizing: border-box;
}
.thumbnail img {
max-width: 100%;
height: auto;
border: 5px solid white;
border-radius: 5px;
box-sizing: border-box;
}
<div class="gallery">
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
</div>
JSFiddle: http://jsfiddle.net/ntbh1rmk/
well since i need 50 reputation to comment (very stupid restriction in my opinion).. i was going to ask why you have 100% for width and height, then add 5px padding to it? isn't that like making it 100% + 10PX?
.thumbnail img{
width:100%;
height:100%;
border:5px solid white;
border-radius:5px;
maybe it's just how i'm being taught... (i'm in CSS class now).. but thats always been a bad thing.
Related
website :https://wells-demo.squarespace.com/
Need logo in center of page section excluding left sidebar(header) in squarespace WELLS template on all format mobile,desktop etc.I am trying to figure out but no result.following is my code
$(document).ready(function(){
$('#headerWrapper #header ').after('<div id="logo1" data-content-field="site-title"><h1 class="logo image" data-shrink-original-size="23" style="letter-spacing: 0.0869565em;"><img src="//static1.squarespace.com/static/5adfd10929711421a9b29d21/t/5adfdbac562fa79909bad158/1524908392416/?format=750w" alt="L ETO BRIDAL" width="130" height=50"></h1></div>');
});
#logo{display:none;}
#headerWrapper{top:4px!important}
#logo1 h1 a img {
height:70px!important;
}
#logo1 {
left: 300%;
position: absolute;
text-align: center !important;
top: 10px !important;
transform: translateX(-50%);
Based on your current CSS, this should do it:
#logo {
width: 100%;
text-align: center;
}
#media (min-width: 801px) {
#logo {
position: fixed;
width: calc(100% - 340px);
top: 0;
margin-left: 240px;
box-sizing: border-box;
background-color: #ffffff85;
padding: .5rem 0;
border-bottom: 1px solid #fff;
}
}
Note: in current form, your question is not really useful to future visitors.
You can read the structure i made below using w3.css from w3schools. I have given a border colour to every div so you can see the boundary of that div and it will make it easy to learn for you.
.outer
{
border:1px solid red;
min-height:100px;
width:100%;
}
.inner-left
{
border:1px solid green;
}
.inner-right
{
border:1px solid blue;
}
.centetr
{
text-align:center;
}
.photo
{
width:95%;
margin:0px auto;
height:40px;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-container outer">
<!--left side-->
<div class="w3-quarter inner-left">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
</div>
<div class="w3-rest inner-right">
<div class="w3-container w3-margin-bottom centetr">
NAME
</div>
<div class="w3-container">
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
</div>
</div>
</div>
I would like to insert a line in the bottom of a div.
My html file :
<div style="position:relative">
<div style="float:left;width:350px;height:360px;position:relative">
<img style="position:absolute;left:0;" class="circular c_imgs" src="Edit.jpg"/>
<img style="position:absolute;left:0;margin-top:175px" class="circular c_imgs" src="lessons.jpg"/>
<img style="position:absolute;right:0;" class="circular c_imgs" src="makeup.jpg"/>
<img style="position:absolute;right:0;margin-top:175px" class="circular c_imgs" src="fun.JPG"/>
</div>
<hr color="#337AB7" size="10" width="%100" style="position:absolute;bottom:0" >
</div>
what is my wrong ?
updated
my css :
.bottomdiv:after{
content:'';
width:100%;
height:10px;
position:absolute;
bottom:0;
background:#337AB7;
border-radius:5px;
}
my html file :
<div class="remodal" data-remodal-id="modal">
<div class="bottomdiv" style="position:relative">
<div style="float:left;width:350px;height:360px;position:relative">
<img style="position:absolute;left:0;" class="circular c_imgs" src="../../../20100202-Cooking-090-Edit.jpg"/>
<img style="position:absolute;left:0;margin-top:175px" class="circular c_imgs" src="../../../lessons.jpg"/>
<img style="position:absolute;right:0;" class="circular c_imgs" src="../../../makeup.jpg"/>
<img style="position:absolute;right:0;margin-top:175px" class="circular c_imgs" src="../../../fun.JPG"/>
</div>
</div>
</div>
But...
It should be 100% instead of %100:
<hr color="#337AB7" size="10" width="100%" style="position:absolute;bottom:0" >
Another easy way to do it is with CSS :after:
div:after{
content:'';
width:100%;
height:10px;
position:absolute;
bottom:0;
left:0;
background:#337AB7;
border-radius:5px;
}
<div></div>
Why don't you try wrapping all of your images inside a div .inner - then apply a border to the bottom of that... With a little tweaking you can position your images relative in a grid and add a clearfix so the inner will clear them and the line will come out of the bottom of the modal.
body {
background: #999
}
.modal {
padding: 30px;
max-width: 680px;
margin: auto;
background: white;
border-radius: 4px;
border: 1px solid #f1f1f1;
box-shadow: 0 0 8px;
}
.inner {
border-bottom: 4px solid blue;
padding-bottom: 20px;
}
img{
width: 46%;
margin: 2%;
height: 200px;
float: left;
background: aliceblue;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
<div class="modal">
<div class="inner clearfix">
<img class="circular c_imgs" src="Edit.jpg"/>
<img class="circular c_imgs" src="lessons.jpg"/>
<img class="circular c_imgs" src="makeup.jpg"/>
<img class="circular c_imgs" src="fun.JPG"/>
</div>
</div>
Pen here
I am having problems with formatting my html 3x3 gallery created with div's. Here is how it looks like now:
http://codepen.io/makkam121/pen/EisKd
.gallery {
width: auto;
margin: 50px auto;
padding: 10px;
border: 2px solid black;
}
.gallery_row {
margin: 10px 10px 10px 0px;
width: auto;
}
.gallery_image {
width: auto;
display: inline-block;
margin-right: 10px;
}
img {
border: 2px solid black;
padding: 10px;
background-color: #BBAABB;
}
<div class="gallery">
<div class="gallery_row">
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
</div>
<div class="gallery_row">
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
</div>
<div class="gallery_row">
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
<div class="gallery_image">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Wilderness_road.jpg/70px-Wilderness_road.jpg" alt="">
</div>
</div>
</div>
I want the gallery to align to the center of the page automatically as the number of images in a row may vary. Instead, I am getting a div with a huge right margin reaching to the right edge of the page. And additionally, I want the spacing between the items and the outer border to be equal(they're not...).
What am I doing wrong? I would appreciate any help.
http://codepen.io/anon/pen/mgqeJ
.gallery{
width:auto;
margin: 0auto;
width:100%;
text-align:center;
border:2px solid black;
}
.gallery_row{
margin:2%;
width:auto;
}
.gallery_image{
width:auto;
display:inline-block;
margin:2% 5% 2% 5%
}
img {
border:2px solid black;
padding:20%;
background-color:#BBAABB;
}
So I'm making a pinterest-style page where there are four divs per row and there can be an unlimited number of rows. The problem that I've ran into is that if the height of the divs are not all the same, the divs will go all over the place.
This is what I mean:
What Should happen:
What Actually happens:
My code (I need to keep it simple and can't do four larger divs for each column because of some php stuff that I've added):
<div id="newsList">
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
<div>
<img src="#">
<p>Text.</p>
</div>
</div>
CSS:
#newsList {
width: 1330px;
margin: 0 auto 0 auto;
display: table;
height: auto;
overflow: auto;
}
#newsList > div {
width: 313px;
height: auto;
float: left;
cursor: pointer;
margin-left: 15px;
position: relative;
overflow: auto;
border-radius: 2px;
background-color: white;
margin-bottom: 16px;
display: inline-block;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.22);
transition: all 0.3s ease-in-out;
}
Place the an outside container div that contains the divs with the content div that you would like to place inside them that way they can all be different lengths that way that the website pinterest does it.
.container {
width:150px;
float:left;
}
.Blue {
width:140px;
padding:2px;
margin:5px;
background-color:blue;
}
.Green {
width:140px;
padding:2px;
margin:5px;
background-color:green;
}
Here is a fiddle link: http://jsfiddle.net/ztdgz24n/1/
This is what I'm trying to achieve. My problems are of course at generating the thumbnails right. What I tried is using a shadow rather than a border for the grey outline and I intended to put a margin for the thumbnails so they get to have the common outline you can probably see. I'm pretty much out of ideas and approaches to getting this to work so I would like to hear your suggestions. Thing is I want this to be responsive so I gave percent dimensions to the thumbnails and all. Here is the code:
<div class="gallery preview">
<div class="main frame">
<img src="images/pic-1.png" class="img-responsive" alt="a">
</div>
<div class="navigation">
<div class="control left">
<i class="fa fa-fw fa-chevron-left"></i>
</div>
<div class="thumb clearfix">
<div class="frame">
<img src="images/pic-1-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-2-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-3-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-1-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-2-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-3-thumb.png" class="img-responsive" alt="a">
</div>
<div class="frame">
<img src="images/pic-1-thumb.png" class="img-responsive" alt="a">
</div>
</div>
<div class="control right">
<i class="fa fa-fw fa-chevron-right"></i>
</div>
</div>
</div>
and the css:
.preview.gallery {
margin: 10px 0;
}
.preview.gallery .frame {
border-radius: 3px;
}
.preview.gallery .thumb {
max-width: 508px;
float: left;
margin: 1px;
}
.preview.gallery .navigation .control {
width: 22px;
display: block;
}
.preview.gallery .navigation .control.left {
float: left;
}
.preview.gallery .navigation .control.right {
float: right;
}
.preview.gallery .thumb .frame {
width: 14.28571428571429%;
display: block;
float: left;
}
.preview.gallery .thumb .frame img {
width: 100%;
}
.preview.gallery .frame {
box-shadow: 0 0 1px 0 rgba(0,0,0,0.5);
}
.preview.gallery .main.frame {
border: 8px solid #fff;
}
.preview.gallery .navigation .control {
background: #fff;
line-height: 74px;
box-shadow: 0 0 1px 0 rgba(0,0,0,0.5);
margin-top: 1px;
border-radius: 3px;
}
1. Set the position of .navigation to relative (so that we can place the two controls on the side of this fluid div):
.navigation {
position:relative;
}
2. Add to .preview.gallery .navigation .control this css code:
.preview.gallery .navigation .control {
position:absolute;
top:0;
}
3. and to the left navigation div:
.preview.gallery .navigation .control.left {
left:0;
}
4. and to the right navigation div:
.preview.gallery .navigation .control.right {
right:0;
}
5. Finally change the margin on .preview.gallery .thumb to:
.preview.gallery .thumb {
margin:0 22px; /* or whatever width you have on the controls */
}
DEMO.
Note
You mentioned wanting some space between the thumbnail and the border. In order for that to work with the percentege values you assigned them, you will want to add this code too:
.preview.gallery .frame {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}