css-position


how to create adjustable gap between elements (div)


im trying to create an even and adjustable gap between divs but i can find an elegant way to do so. thanks for your help.
how i dont want it
and how i want
this is the only way i found in order to create the gap but im sure there is a better way.
#big {
height: 500px;
width: 500px;
border: 1px solid #FF0000;
border-radius: 5px;
margin:auto;
position:relative;
top:;
right:
left:
}
.small {
height: 50px;
width: 100px;
border: 1px solid #FF0000;
border-radius: 5px;
background-color: #308014;
margin:4px;
position:relative;
top:150px;
left:200px;
}
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Result</title>
</head>
<body>
<div id="big">
<div class="small"></div>
<div class="small"></div>
<div class="small"></div>
<div class="small"></div>
</div>
</body>
</html>
Either u can give margin-bottom or padding-bottom but for last div margin bottom is not necessary.
so you can try
.small{
margin: 0 0 4px 0
}
.small:last-of-type{
margin-bottom:0;
}

Related Links

fixed position z-index not working
how to create adjustable gap between elements (div)
How to properly apply a css hack for IE11 transition misbehaviour
How do you make leaflet popup window full screen on small screens?
Fix a div to the bottom while scrolling with skrollr
Sticky Footer at bottom of PAGE, not just bottom of WINDOW
How to set div absolute position from the parent div
Polymer paper-fab with position:fixed behaves strangely when used with core-list that has a scrollTarget
What is the use of “static” positioning in CSS?
CSS: fixed position
Style sheet positioning won't keep everything in place
Div on top 100%
CSS float image align
google sites html box tool css postion absolute
Manual Positioning of Shareaholic ShareBar Plugin
Div position (margin:auto)

Categories

HOME
android
phantom-dsl
grok
eclipse
azure-stream-analytics
cobalt
eslint
forms
apache-jena
devise
opendj
simulink
emscripten
character
elasticsearch-5
commonjs
mod-security
package-managers
android-7.0-nougat
video-editing
lilypond
rubymotion
imageresizer
zxing
gmock
mount
comparable
corenlp-server
aws-codecommit
paragraph
protege4
unordered-map
skylink
install.packages
clang++
flask-restful
wcftestclient
configurationmanager
lightning
arq
amq
context-switch
avx
sandcastle
rmongo
usart
latin
myspace
resourcemanager
gogs
qiime
project-organization
libav
kendo-upload
maybe
poppler
fuelcms
skspritenode
pyobjc
delayed-execution
filesplitting
teaspoon
create.js
authlogic
gtm-oauth2
breakout
mbunit
jquery-1.9
pclzip
stacky
cardreader
asplinkbutton
pdfviewer
boost-msm
convention
pylucene
objective-j
uideviceorientation
qtabbar
burndowncharts
build-environment
tui

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App