Nick
Nick

Reputation: 7525

CSS for top right corner of the page

How would I have a top right corner div as shown in the image. I want to do something similar though not exactly the same. I think the text is not an image.

alt text

Also, I have seen some websites that has a page hover effect when a mouse is over the top right section. Any idea how to do that?

Upvotes: 7

Views: 26617

Answers (5)

samad montazeri
samad montazeri

Reputation: 1273

you may want to take a look at this JSFiddle:

Css:

.wrapper {
  margin: 50px auto;
  width: 280px;
  height: 370px;
  background: white;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
  position: relative;
  z-index: 90;
}

.ribbon-wrapper-green {
  width: 85px;
  height: 88px;
  overflow: hidden;
  position: absolute;
  top: -3px;
  right: -3px;
}

.ribbon-green {
  font: bold 15px Sans-Serif;
  color: #333;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: 7px 0;
  left: -5px;
  top: 15px;
  width: 120px;
  background-color: #BFDC7A;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45)); 
  background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45); 
  color: #6a6340;
  -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

.ribbon-green:before, .ribbon-green:after {
  content: "";
  border-top:   3px solid #6e8900;   
  border-left:  3px solid transparent;
  border-right: 3px solid transparent;
  position:absolute;
  bottom: -3px;
}

.ribbon-green:before {
  left: 0;
}
.ribbon-green:after {
  right: 0;
}

html:

<div class="wrapper">
       <div class="ribbon-wrapper-green"><div class="ribbon-green">NEWS</div></div>
</div>

Upvotes: 2

Ahoodie
Ahoodie

Reputation: 61

Make sure it's a transparent PNG

#Element {
   position: fixed;
   top:0;
   right:0;
z-index:10;
}

(An element with greater stack order is always in front of an element with a lower stack order.)

Upvotes: 6

jps
jps

Reputation: 11605

If the text isn't an image, none of the other answers will work. Here is some css that rotates a div 45 degrees and works in IE + FF + Webkit.

#yourdiv
{
    top: 0px;
    right: 0px;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
     transform: rotate(45deg);
     filter: progid:DXImageTransform.Microsoft.Matrix(M11='0.7071067811865476', M12='-0.7071067811865475', M21='0.7071067811865475', M22='0.7071067811865476', sizingMethod='auto expand');
}

Upvotes: 11

animuson
animuson

Reputation: 54757

div.topRight {
    position: absolute;
    top: 0%;
    right: 0%;
}

This will assign a division with class set as 'topRight' to the top right corner. I'm sure you can figure out how to get the image to show up properly from that. Make sure you set the proper width and height on it. As for hovering, what exact effects do you want? You can modify the CSS on hover easily, if that's all you want to do.

div.topRight:hover {
    // new css rules
}

Upvotes: 5

KTastrophy
KTastrophy

Reputation: 1739

I'm assuming you want fixed positioning.

#Element {
   position: fixed;
   top:0;
   right:0;
}

Upvotes: 0

Related Questions