1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

element clipping Css

Discussion in 'CSS' started by A Curry, Jun 13, 2014.

  1. #1
    I need to clip some content that is 20px wide by 20px high and situated in the top left corner. Now ive read this section 3x in my textbook and the only syntax they show is clip: rect(t,r,b,l) format so Im a little unsure what 20wide by 20high is. Do they just want me to use width and height properties instead of clip: rect(0,0,0,0)? Here is what I currently have:

    figure{
    background-color: rgb(70,76,222);
    color: #fff;
    width: 150px;
    position: absolute;
    z-index: 1;
    /* left: 20px;
    top: 20px;*/
    clip: rect(20px,20px);
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    -ms-border-radius: 15px;
    -o-border-radius: 15px;
    border-radius: 15px;

    }
     
    A Curry, Jun 13, 2014 IP
  2. COBOLdinosaur

    COBOLdinosaur Active Member

    Messages:
    281
    Likes Received:
    66
    Best Answers:
    8
    Trophy Points:
    55
    #2
    Clip values are not defining dimension they represent the distance from the edge of the element that is to be removed. So if the image you are clipping was 200 by 150 and yo wanted just the center 20 px the values would be clip:rect(90px,65px, 90px, 65px);
     
    COBOLdinosaur, Jun 13, 2014 IP
  3. deathshadow

    deathshadow Prominent Member

    Messages:
    6,497
    Likes Received:
    963
    Best Answers:
    161
    Trophy Points:
    395
    #3
    I don't get the need for "clip"... Just set the dimensions on the container and set overflow:hidden;
     
    deathshadow, Jun 14, 2014 IP
  4. COBOLdinosaur

    COBOLdinosaur Active Member

    Messages:
    281
    Likes Received:
    66
    Best Answers:
    8
    Trophy Points:
    55
    #4
    Using overflow would only work if you want the top left corner. For anything else you would have to use position with negative values to get the part of the image in the visible portion of the container. A soon as you get into setting position that way it can turn a page ugly.
     
    COBOLdinosaur, Jun 15, 2014 IP