Breadcrumb's triangles using images and :before, :after pseudoelements - css

Problematic part:
.breadcrumbs a:before, .breadcrumbs span:before {
background: url('');
width: 10px;
height: 20px;
background-position: 0 -147px;
content: '';
position: absolute;
}
I am trying to make some padding for the text but I can't find any workaround that wouldn't affect image from the :before pseudoelement.
Here's my code: http://jsfiddle.net/ZARUz/
I am trying to obtain that effect: http://cl.ly/SVBR

http://jsfiddle.net/TreeTree/ZARUz/12/
.breadcrumbs a, .breadcrumbs span {
height: 20px;
background: url('http://s1.pixelize.pl/breadcrumb.png');
background-position: 0 -21px;
display: inline-block;
position:relative;
padding-right:10px;
}
.breadcrumbs a:after, .breadcrumbs span:after {
background: url('http://s1.pixelize.pl/breadcrumb.png') white;
width: 10px;
height: 20px;
background-position: 0 -63px;
content:'';
position: absolute;
right:0;
}
.breadcrumbs a:before, .breadcrumbs span:before {
background: url('http://s1.pixelize.pl/breadcrumb.png');
width: 10px;
height: 20px;
background-position: 0 -147px;
content:'';
position: absolute;
left:-10px;
}
Your pseudos weren't given left and right properties which made them slightly unpredictable.
I assumed by
that wouldn't affect image from the :before pseudoelement.
you meant modifying the actual image file, so this method doesn't do that.

Need to position your before and after "blocks" so the backgrounds can appear correctly.
A JSFiddle Lives Here
.breadcrumbs a, .breadcrumbs span {
height: 20px;
background: url('http://s1.pixelize.pl/breadcrumb.png');
background-position: 0 -21px;
display: inline-block;
position: relative;
padding: 0 10px;
margin-right: 30px;
}
.breadcrumbs a:after, .breadcrumbs span:after {
background: url('http://s1.pixelize.pl/breadcrumb.png');
width: 10px;
height: 20px;
background-position: 0 -63px;
content: '';
position: absolute;
right: -10px;
}
.breadcrumbs a:before, .breadcrumbs span:before {
background: url('http://s1.pixelize.pl/breadcrumb.png');
width: 10px;
height: 20px;
background-position: 0 -147px;
content: '';
position: absolute;
left: -10px;
}

Related

Margin not giving any results on divs

I'm not any kind of CSS pro. But margin doesn't seem to work in any other parts than the ul/li list provided below.
I have played with positions and other divs.
html, body {
margin: 0;
padding: 0;
}
body {
background-color: rgb(184, 184, 184);
background-repeat: no-repeat;
background-position: center;
background-size: auto;
background-image: url('/images/landing.jpg');
font-family: Montserrat;
}
.header {
top: 0;
position: fixed;
background-color: gray;
width: 100%;
height: 60px;
justify-content: center;
align-items: center;
display: flex;
}
.menu {
position: fixed;
top: 6px;
right: 0;
}
.menu ul li {
display: inline;
}
.menu ul li a {
color: white;
text-decoration: none;
font-size: 16px;
font-weight: lighter;
padding: 0 20px;
}
.welcome {
position: absolute;
color: white;
font-size: 50px;
top: 459px;
margin: auto;
}
HTML:
<div class='welcome'>
<span>Hello!</span>
</div>
Trying to get welcome div to center
You are setting margin: auto on an absolute positioned element. I suppose you are trying to center the 'welcome' element (as per your question, this fact is not clear). An absolute positioned element is dependent on its ancestors positioning and size.
One of the many solutions to center an absolute positioned element if to move it to 50% from the top and left of it's parent, and than apply translate to nudge it to the center: top: 50%; left: 50%; transform: translateX(-50%) translateY(-50%).
welcome class position is absolute so welcome class parent should be relative to center the welcome div. And also if you want to horizontally center the div you should change margin: auto; to margin: 0 auto;
Or you can make the parent div display to flex, then use align-items, justify-content to center.
.parent { display: flex, align-items: center, justify-content: center }
Try changing your welcome css class to this:
.welcome {
position: absolute;
left: 50%;
transform: translate(-50%);
}
Replace your .welcome css class with this css code :
html, body {
margin: 0;
padding: 0;
}
body {
background-color: rgb(184, 184, 184);
background-repeat: no-repeat;
background-position: center;
background-size: auto;
background-image: url('/images/landing.jpg');
font-family: Montserrat;
}
.header {
top: 0;
position: fixed;
background-color: gray;
width: 100%;
height: 60px;
justify-content: center;
align-items: center;
display: flex;
}
.menu {
position: fixed;
top: 6px;
right: 0;
}
.menu ul li {
display: inline;
}
.menu ul li a {
color: white;
text-decoration: none;
font-size: 16px;
font-weight: lighter;
padding: 0 20px;
}
.welcome {
left:50%; right:50%;
top:50%; bottom:50%;
position: absolute;
}
<div class='welcome'>
<span>Hello!</span>
</div>

Span inside div is crossed by div

<div class="message-unread-headline" id="message-unread-headline" style="display: none;">
<span>Unread Messages</span>
</div>
.message-unread-headline {
color: #e91e63;
display: none;
margin: 0 10px -10px;
position: relative;
text-align: center;
&:before {
background: #e91e63;
content: '';
height: 2px;
left: 0;
padding: 0 10px;
position: absolute;
top: 0;
width: 100%;
}
span {
background: transparent;
display: inline-block;
height: 30px;
padding: 0 10px;
position: relative;
top: -11px;
}
}
this is how it looks
I would like that pink line stops as soon as reaches the Unread Message Text
I tried with z-index, but it doesn't work. Don't know the way how to prevent that overlaying
That's how I achieved this:
.message-unread-headline {
margin:0;padding:0 10px;
background:#fff;
display:inline-block;
color: #e91e63;
}
h2{
text-align:right;
position:relative;
z-index:2;
}
h2:after{
content:"";
position:absolute;
top:50%;
left:0;
right:0;
border-top:solid 2px #e91e63;
z-index:-1;
}
<h2>
<span class="message-unread-headline">Unread Messages</span>
</h2>
Check if this could help you.
I have removed width: 100% and added right: 0 to :before
And give background: #fff; to span
.message-unread-headline {
color: #e91e63;
position: relative;
text-align: right;
}
.message-unread-headline:before {
background: #e91e63;
content: '';
height: 2px;
left: 0;
padding: 0 10px;
position: absolute;
top: 0;
right: 0;
}
.message-unread-headline span {
background: #fff;
padding: 0 10px;
position: relative;
top: -11px;
}
<div class="message-unread-headline" id="message-unread-headline" >
<span>Unread Messages</span>
</div>
If your purpose is just strike over a text you can go for strike tag in html

Assistance require for css hover image

I am on the process in learning css.
I am trying to display the image in the middle of the screen upon user hover their mouse in the gallery.
however, the image hover within the image itself.
this is my code.
jsfiddle.net/y9w5ym72/1/
body {
margin: 0;
padding: 0;
background: #EEE;
font: 10px/13px 'Lucida Sans',sans-serif;
}
.wrap {
overflow: hidden;
margin: 50px;
}
.box {
float: left;
position: relative;
width: 25%;
padding-bottom: 25%;
color: #FFF;
}
.boxInner {
position: absolute;
left: 30px;
right: 30px;
top: 30px;
bottom: 30px;
overflow: hidden;
background: #66F;
}
.boxInner img {
width: 100%;
}
.thumbnail:hover img{
border: 1px solid transparent;
}
.thumbnail span{
position: absolute;
padding: 5px;
left: -1000px;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span img{
border-width: 0;
width:70%;
height: auto;
padding: 2px;
}
.thumbnail:hover span{
visibility: visible;
top: 0;
left: 230px;
z-index: 50;
}
First point is you need to hide the first image. So that only you can see the second one. Second point is no need position:absolute, left:-1000px; styles for the inside span.
.thumbnail:hover > img{
border: 1px solid transparent;
display:none;
}
.thumbnail span{
/*position: absolute;
left: -1000px;*/
padding: 5px;
visibility: hidden;
color: black;
text-decoration: none;
}
DEMO
you have to use position :absolute to achieve that fiddle
.box:hover{position:absolute; top:38%; left:38%; z-index:200;}

Responsive / Relative Positioning Background Image

Issue I'm having is the background image on the anchor as a before element needs to move with the text as you resize your screen.
I need the background image to maintain it's position ( e.g left: 20px;) with the text as you resize your screen.
Here is my CSS:
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
float: left;
width: 50%;
}
ul li a {
display: block;
padding: 15px 20px;
text-align: center;
text-decoration: none;
font-weight: bold;
position: relative;
color: #717171;
}
ul li a:before {
background: url(http://graphicclouds.com/wp-content/uploads/img/73-google-style-icons-thumb.jpg) no-repeat -11px -26px;
content: '';
display: block;
width: 34px;
height: 33px;
position: absolute;
top: 10px;
}
.link-1:before {
left: 20px;
}
.link-2:before {
left: 0px;
}
Here is a working example: http://jsfiddle.net/2KHS6/
All suggestions welcome
New version:
http://jsfiddle.net/2KHS6/5/
Hope it fills your needs. You might want to set a min-width to avoid problems with small screens though. I did this basically:
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
display: inline-block;
width: 50%;
margin: 10px 0;
/* So things don't get crazy */
min-width: 160px;
/* center the child, the <a> */
text-align: center;
}
ul li a {
display: inline-block;
text-decoration: none;
font-weight: bold;
color: #717171;
/* Should be the same height as the img so it stays centered */
line-height: 33px;
}
ul li a:before {
background: url(http://graphicclouds.com/wp-content/uploads/img/73-google-style-icons-thumb.jpg) no-repeat -11px -26px;
content: '';
display: block;
width: 34px;
height: 33px;
position: absolute;
/* position the image at the left of the a. There are many methods to do this actually */
margin: 0 0 0 -50px;
}

create image map with css?

i create image map with css but don't work.
i have a image in background and i want to create a image map for background picture .but when my mouse hover an link background image not change.
this is my html code.
<section id="centersectioncontact" class="colortext">
<ul id="cantact">
<li id="linkin">Link in </li>
<li id="twiter"> twiter</li>
</ul>
</section>
and this is my css code.
#centersectioncontact {
position: absolute;
top: 14%;
left: 31%;
width: 426px;
height: 426px;
bottom: 25%;
right: 25%;
z-index: 2;
}
ul#cantact
{
list-style:none;
background:url(../Images/contact.png) no-repeat 0 0 ;
position:relative;
width:426px;
height:420px;
margin:0;
padding:0;
opacity:0.5;
}
ul#cantact li{
position: absolute;
border: 1px solid #000;
}
}
ul#cantact a{
display: block;
height: 100%;
text-indent: -9000px;
}
#linkin {
width: 215px;
height: 140px;
top: 0px;
left: 0px;
}
#twiter
{
width: 215px;
height: 140px;
top: 0px;
left: 215px;
}
ul#cantact li a:hover {
background:url(../Images/contact.png) no-repeat 0 0;
}
ul#cantact li#linkin a:hover {
background-position: 0 -426px;
}
ul#cantact li#twiter a:hover{
background-position: 0 -426px;}
.colortext{
margin-top: 7px;
margin-left: 16px;
top: 2%;
left: 2%;
color: #FFFFFF;
text-align: left;
font-size: xx-large;
z-index: 10000000;
}
there is a couple of contradictions in your css code. One of these and an extra '}' cause the problem:
from
ul#cantact li{
position: absolute;
border: 1px solid #000;
}
}
delete the extra "}"
and you should remove also:
ul#cantact li#linkin a:hover {
background-position: 0 -426px;
}
ul#cantact li#twiter a:hover{
background-position: 0 -426px;
}
In the code you have already defined background-position as 0 0 in
ul#cantact li a:hover {
background:url(../Images/contact.png) no-repeat 0 0;
}
And besides, with the -426px horizontal setting the img won't reveal on the screen.

Resources