How to remove left and right margin on first and last div


Tags: css,css3

Problem :

I have more than 100 divs on the page and each row has 3 divs. I want to remove left margin from first div and right margin from right div whereas center div should have 15px margin from left and right. Please guide me how can I do that without giving specific classes (no margin) on each div. Here is the example

enter image description here here is my css code

.prp_box{
    margin:15px 15px;
    width:100px;
    height:100px;
    background:#5f03a6;
    }


Solution :

Check this out : http://jsfiddle.net/VHXEp/

Use nth-child(n) CSS3 selector.


    CSS Howto..

    how can css reset :hover to default state?

    how to overlap two div in css?

    CSS breadcrumb - how to make radius small

    How to repeat multiple images over one element using CSS

    How to create borders in bootstrap when div is 0 height

    Bootstrap - how to clear css from element to start over?

    How can I format all td elements contained in a table with class myclass in CSS?

    How to have different layout orders for same html code for desktop and desktop using css or javascript (not jquery)

    How to target images with dynamically generated ids with CSS

    How to fade in and out a CSS “:after” pseudo element when adding or removing a class

    How to set the background image of an DIV in CSS?

    How to put bootstrap glow (used in the 'form-control' CSS class) on a div?

    How to resize div size proportional with browser size?

    How to make float navbars with JS and CSS?

    How to prevent document scrolling but allow scrolling inside div elements on websites for iOS and Android?

    How to align text and image in xslt with css

    How to call JavaScript on change of CSS

    How do I use PHP to apply css properties? [closed]

    How can I setup a border inside the div

    How to overlap two SVG vectors without using inline SVG?

    How to display first tab by default in css?

    How to fix too long css dropdown in Foundation 4 top bar?

    How to create a curve tail for speech bubble with CSS?

    By CSS, how to make page height not change when an element is moved down

    How to make layout like notes in Google Keep using CSS?

    How to check for text created by CSS?

    How to define a Click handler function for multiple elements at the same time

    How to open a CSS-only popup automatically on page load/using Javascript?

    How to align an element applying css margins that does not get modified according to browsers and screen resolutions?

    CSS How to set div height 100% minus nPx