Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Hi there,
This is in regards to the image I posted above. I feel like it's something that should be easy, but I just can't figure it out. I basically have a DIV that is the container with the darker see through BG and inside it I have some text that's centered. To the left and right of the text I have these horizontal lines of equal width.
Now the trick is that those horizontal lines, change their width based on how much text I have in the middle so there's always the same "padding" around the sides of the text. It's important to note that the background is not a flat color, but an image and the container with the darker BG is see through. If it was a flat color I could just add a thick shadow to the text of the same color as the BG and just have that line be the background of that DIV all the way through in which case the shadow of the text would make it look as its interrupted behind the text. The container also has a dynamic width, something like 80% for example.
Anyone have any idea how I could get this done? Thank you very much in advance!
You can use pseudo element and rgba() colors, this is a common way to do it : DEMO
HTML test
<header>
<h1> MY CENTERED TEXT</h1>
</header>
CSS test
header {
padding:3em;
background:url(http://lorempixel.com/600/50/nightlife) ;
background-size: cover;
}
h1 {
background:rgba(0,0,0,0.5);
color:white;
padding:1em 0;
text-align:center;
overflow:hidden;
}
h1:before, h1:after {
content:'';
width:100%;
border-bottom:lightgray solid;
display:inline-block;
vertical-align:middle;
}
h1:before {
margin-left:-100%;}
h1:after {
margin-right:-100%;}
Related
This question already has an answer here:
Is there an easy way to contrast text over an image using css?
(1 answer)
Closed 2 years ago.
I would like to achieve the effect as per the attached image (via https://thierrychopain.com).
I have tried using mix-blend-mode: difference; (and other variants) but obviously that just inverts the background image too, whereas I would simply like to change the font colour as the background changes. I cannot immediately see how else this could be done via CSS. After inspecting the website itself (https://thierrychopain.com), I still can't see how the designer has achieved this in CSS alone.
How can this be done?
In looking at the page, the designer pulls a visual trick on you. There's actually two separate copies of that text. One inside the image display block and one outside. The one outside lies beneath it, and is black. The one inside is white, but overflow:hidden on the image container constrains it.
By carefully aligning the text to where it gets cut off, you see that effect.
Here's a quick example to demonstrate the technique. (Note: Since it's just a demo I didn't make it play well on mobile.)
JS Bin Example:
https://jsbin.com/loxulil/3/edit?output
If you know the width of the images before hand, You can try something like this.
The first background to color the text inside the image, and the second is for the rest of the text.
div {
/* to center text vertically and horizontally */
display: flex;
background: url(https://picsum.photos/200/300) center no-repeat;
padding: 50px;
}
h1{
/* to center text vertically and horizontally */
margin: auto;
background: linear-gradient(white, white) center/200px 100% no-repeat, black;
-webkit-background-clip: text;
color: transparent;
}
<div>
<h1>I'm not a Header Title</h1>
</div>
re-run the snippet for a different image.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a carousel slider which works perfectly in large screens. But when the same is viewed in small devices, a extra space of gray background is added. The same can be viewed in (ctrl+shift+m) in firefox of this SITE LINK . When viewed in firebug, I have noticed that it might due to
element.style {
height:345.6px
}
If I remove the height, it works perfectly. How to fix this ?
UPDATE: If no slider appears, please select change city to Guwahati
I would need more information to help you. Are you using some kind of template? Do you have access to the the raw HTML or CSS? Please be more clear about how we can help.
Edit:
True this should be a comment. Sorry about that. Give the element a specific class and override the template CSS. Something like this:
HTML:
<section id="home" class="customHeightStyle home-section home-parallax home-fade bg-dark-30" data-background="" style="height: 480.24px; top: 0px; background-position: 82px 38px, 44px 31px, 22px 15px;">
CSS:
.customHeightStyle {
height: auto !important;
}
In html, add the same image as background for the parent .item. And use background-size:cover;
For small screen sizes, hide the image using opacity or visibility.
Increase the height of .carousel, .carousel-inner and .item to 100%.
Because you have set height of the container element and then styled the image to be 100% in width.
The upper image is trying to preserve best aspect ratio. You need to set the height of containers properly and then try adding images as cover photos to individual sliders with background-image and background-size property.
Remove youe section style height: 5371.2px;
<section id="home" class="home-section home-parallax home-fade bg-dark-30" data-background="" style="background-position: 20px 8px, 11px 6px, 5px 3px;">
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Can't set the border property at the bottom of my html window/viewport...
It's just after the last html element. e.g. div.
Is there a way, so it will be displayed really at the bottom of the window?
Here is my css:
html {
border-bottom:5px solid rgb(17,17,17);
border-top:5px solid rgb(17,17,17);
}
Thanks very much!
In your html add
html {
width:100%;
/*height:99%; Fallback for older browsers*/
height:calc(100% - 10px);
border-bottom:5px solid rgb(17,17,17);
border-top:5px solid rgb(17,17,17);
}
I think this will fix your problem.
Here is the Demo
Try setting your body tags margin and padding to 0px.
You need to specify width and height.
html{
border-bottom:5px;
border-bottom-color:rgb(17, 17, 17);
border-bottom-style:solid;
border-top:5px;
border-top-color:rgb(17, 17, 17);
border-top-style:solid;
width:100%;
height:100%;
}
(here's an imgur album to compare the difference: http://imgur.com/a/Uneo5 notice how in the first image, there's a whitespace under it, which appears to be your issue, whereas with height and width, it reaches the bottom of the document)
Edit: And if you have issues with a scrollbar, try 99%, or 99.5%, etc.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a div at the bottom at a page. it's not bound by any other div. How would I manage to align it, a bit off center, with the main div. And place it at the top of the page, when the page has different heights and the div has to have a z-index:1;
The two divs top has to be aligned, one cannot be higher than the other.
The html
<body>
<div id="Main"><div> //Css or html for this div can not be edited
<div id="Our_hero_div"><div> //This has to be show ontop of main, but a bit off-center
</body>
CSS
#Our_hero_div{
z-index:1; //this much remain
}
#main {
margin:auto;
}
If you cannot get that #Our-hero-div INSIDE of the #main div, and if you cannot edit the CSS of the #main div, your options are limited. You can try to give it an absolute position and align its top with the top of the #main div using the css top property.
#Our-hero-div {
position: absolute;
top: 1em; /* assumes the #main div has a margin top of 1em - just match this value to whatever the margin/padding of the #main div has on top */
}
You'll also need to use left or right to position horizontally (for that off-center thing you're after). This solution only works if that #main div is really at the top of the body. If there's other stuff that changes height above #main, then this falls apart.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Sometimes you want to make an entire div (or other element) into a clickable link. Here’s an example.
Here’s a cross-browser way to do it using pure CSS:
HTML:
<div class="clickable">
Rest of div content goes here
</div>
CSS:
div.clickable { /* Containing div must have a position value */
position:relative;
}
div.clickable a {
position:absolute;
width:100%;
height:100%;
top:0;
left:0;
text-decoration:none; /* Makes sure the link doesn't get underlined */
z-index:10; /* raises anchor tag above everything else in div */
background-color:white; /*workaround to make clickable in IE */
opacity: 0; /*workaround to make clickable in IE */
filter: alpha(opacity=1); /*workaround to make clickable in IE */
}
First, give the containing div position. That way, when we apply “position:absolute;” to the link (see next paragraph) it will position itself relative to the containing div.
Next, make the link absolutely positioned and the full size and depth of the containing div. The link’s z-index makes sure it’s above everything else in the div, so no matter where you click, you’re clicking the link.
IE, naturally, has quirks. In this case, IE requires a background color for such a link to be clickable, so we give it a background color (white), set the opacity to 0, then give it an IE-only opacity of 1% using IE’s proprietary filter property.
Finally, put whatever content you want in the div. If you’re going to be layering the content using z-index, just make sure not to give any element a higher z-index than the link.
You can wrap a div in a link and it is valid HTML5.
<a href="#">
<div></div>
</a>