Put some content before or after a bootstrap container

时间:2015-07-13 21:01:11

标签: html css twitter-bootstrap

I need to have a bootstrap container of one color (let's say red) and then I need to color the space on the right with a different color and the space on the left with another one (actually my situation is more difficult because I have an image behind the container and on the right side of the container I should have a transparent effect, while on the left side I should have a solid color).

Do you have any idea on how to achieve it? I did a simple plunker to show what I'm trying to achieve (I tried with :after and :before but with no success)

http://plnkr.co/edit/rvD9ndy2OfY7kCxn0scP?p=preview

.myDiv{
    background-color : red;
}
.myOuterDiv:after{
    background-color : green;
    content : "  ";
}
.myOuterDiv:before{
    background-color : yellow;
    content : "  ";
}

1 个答案:

答案 0 :(得分:1)

虽然不清楚你想要的是什么,也许你可以考虑使用背景渐变,两个中心位置相互对齐。

像这样。 。 。

http://plnkr.co/edit/OMAfdVi3mK50M1nXNaR7?p=preview

/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#fff000+1,fff000+50,00ff00+51,00ff00+100 */
background: #fff000; /* Old browsers */
background: -moz-linear-gradient(left,  #fff000 1%, #fff000 50%, #00ff00 51%, #00ff00 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(1%,#fff000), color-stop(50%,#fff000), color-stop(51%,#00ff00), color-stop(100%,#00ff00)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left,  #fff000 1%,#fff000 50%,#00ff00 51%,#00ff00 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left,  #fff000 1%,#fff000 50%,#00ff00 51%,#00ff00 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left,  #fff000 1%,#fff000 50%,#00ff00 51%,#00ff00 100%); /* IE10+ */
background: linear-gradient(to right,  #fff000 1%,#fff000 50%,#00ff00 51%,#00ff00 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff000', endColorstr='#00ff00',GradientType=1 ); /* IE6-9 */