How to set Png Border Image correctly - html

I'm trying to set a png to be the bottom border of one div and again at the top of my footer. I've tried border-image as well as using it as the background image for my div, but I've failed to figure it out. Right now I'm just getting a black bar at the bottom of my first div, and a little black mark at the top of my Footer. Any explanation would be greatly appreciated.
Here's my code so far.
Main Page
<div className='about-wrapper'>
<img src='https://image.shutterstock.com/image-photo/gorilla-thinking-260nw-54482215.jpg' alt='Adam Face'></img>
<h2>Name</h2>
<p>Welcome to my site! I am a developer currently developing in ReactJS.</p>
</div>
.about-wrapper {
padding: 20px;
border-bottom: 50px solid transparent;
border-image: url('https://ubisafe.org/images/detorted-clipart-sky-line-1.png') 1%;
background: linear-gradient(#519DFE, #110BFF);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
text-align: center;
height: 100vh;
color: white;
}
Footer
<div className='footer-wrapper'>
</div>
.footer-wrapper {
height: 400px;
background: #001ED4;
border-top: 50px solid transparent;
border-image: url('https://ubisafe.org/images/detorted-clipart-sky-line-1.png') 1%;
Here's what my pages look like
First Div
Footer

The border-image-slice property indicates which parts of the image are used for the border; with only a single value, it will the same percentage of the width and height for the slices.
(Note that I used about 10% in my illustration to make it clear, but it works the same for 1%.) Since you have only a border bottom for the about-wrapper div, only the bottom part will be used.
So if you want the entire picture for a bottom border, the solution is to not use an 1% image slice. You would need 0 0 100% 0 (for top, right, bottom, left respectively). Same with the footer: for the top border there, use 100% 0 0 0.
.about-wrapper {
padding: 20px;
border-bottom: 50px solid transparent;
border-image: url('https://ubisafe.org/images/detorted-clipart-sky-line-1.png') 0 0 100% 0;
background: #110BFF linear-gradient(#519DFE, #110BFF);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
text-align: center;
height: 100vh;
color: white;
}
.footer-wrapper {
height: 400px;
background: #001ED4;
border-top: 50px solid transparent;
border-image: url('https://ubisafe.org/images/detorted-clipart-sky-line-1.png') 100% 0 0 0;
<div class='about-wrapper'>
<img src='https://image.shutterstock.com/image-photo/gorilla-thinking-260nw-54482215.jpg' alt='Adam Face'>
<h2>Name</h2>
<p>Welcome to my site! I am a developer currently developing in ReactJS.</p>
</div>
<!-- Footer -->
<div class='footer-wrapper'>
</div>

Related

Where this orange margin is coming from?

I'm trying to create my portfolio website and I'm not sure where the 78.500 margin on the right side of the image is coming from?
I set my container of that image and the caption underneath in html as:
.main__img--container {
text-align: center;
box-sizing: border-box;
margin: 0;
margin-right: auto;
padding: 0;
}
#main__img {
height: 80%;
width: 80%;
display: flex;
clip-path: circle();
}
.caption {
text-align: center;
font-size: 35px;
display: block;
background-color: #87CEEB;
background-image: linear-gradient(to top, #4169E1 0%, #33cee2 100%);
background-size: 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
}
.caption2 {
text-align: center;
font-size: 20px;
display: block;
align-items: center;
background-color: #87CEEB;
background-image: linear-gradient(to top, #4169E1 0%, #33cee2 100%);
background-size: 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
}
<figure class="main__image--container">
<img src="images/Profile Photo.jpg" class="profile" alt="pic" id="main__img">
<figcaption class="caption">Daichi Furukawa</figcaption>
<figcaption class="caption2">Cognitive Systems under Computer Science at UBC</figcaption>
</figure>
I played around the margin in #main__img, but it didn't change anything.
I would like to get rid of the 78.500 margin so I can put my image more on the right side of the page.
Even when I change the width from % to px, it still creates the margin on the right side of the page...
This margin is generated when you applied width to your image
#main__img {
height: 80%;
width: 80%;
display: flex;
clip-path: circle();
}
Use some other property to achieve the results you're looking for.
The code given in your question is far from complete to really get a reliable answer, but I see that your image has 80% width inside its parent element .main__img--container. So most likely that "margin" is the empty 20% which are left of the container's width. (Also the centered position of the caption in the screenshot you posted would fit to that)
As above, width is set to 80%, leaving 20% of empty space. Try floating it to the right:
float: right;
That should push it all the way to the right and switch the margin to the left of the image instead.

Pure CSS solution for a non-conjested, fault-less, perfectly-repitious dotted line using CSS Background Radial-Gradient

A CSS Layout Problem
Currently I'm not happy with my standard <hr> dotted lines. The results are far from the holy grail dotted lines I was looking for.
hr{
border-bottom: 1px dotted Black;
border-top: none;
margin: 1em 0;
}
Please open image at 100% scaling in a separate window.
The dots are too close to each other and I don't want dashed lines with black stripes. I want dots but with more spacing in between them.
Desire for (and Design of) the Pure Elusive Holy Grail Dotted Line
In my dreams I see in front of me a pure CSS dotted line, like in this image (made in Photoshop).
Please open image at 100% scaling in a separate window.
A horizontal rule that meets the following criteria:
A height of 1px
A repeating pattern of 2 pixels transparent gap followed by a 1 Black pixel
Has a 100% width (give or take 3 pixels)
From the first dot till the last dot, at no point are there dots pushed together (black dots too close together) or pulled apart (more than 2 pixels gap spacing in between Black dots)
A pure CSS layout using CSS Background Radial-Gradient
Where I'm stuck now
I cannot get this to work properly yet. What have I overlooked and why is the following not working?
hr{
background-image: radial-gradient(circle closest-side, Black 100%, Black 100%);
background-position: 0 0, 100% 100%, 0 0;
background-repeat: repeat-x;
background-size: 3px 1px;
}
Until the solution, the search for the elusive holy grail hr remains untackled.
html{ margin: 7em; background: #EEE}
article { background: lightblue; height: 100px; padding: 2em}
hr{
border-bottom: 1px dotted Black;
border-top: none;
margin: 1em 0;
}
hr{
background-image: radial-gradient(circle closest-side, Black 100%, Black 100%);
background-position: 0 0, 100% 100%, 0 0;
background-repeat: repeat-x;
background-size: 3px 1px;
}
<article>
<p> Text </p>
<hr>
<p> Text </p>
</article>
The following code works. Although I have no idea why and how precisely. Other more elegant answers, improvements and suggestions are welcome that can further explain the workings of the magic here.
After many trials I have figured out that the first number represents the gap size and the second number represents the dot width in background-size: 3px 1px;
hr{
border: none;
background-image: radial-gradient(circle closest-side, Black 100%, Transparent 100%);
background-position: 0 50%;
background-repeat: repeat-x;
background-size: 3px 1px; // GAP width and DOT width
height: 1px;
}
html{ margin: 4em; background: #EEE}
article { background: lightblue; height: 100px; padding: 2em}
hr{
border: none;
background-image: radial-gradient(circle closest-side, Black 100%, Transparent 100%);
background-position: 0 50%;
background-repeat: repeat-x;
background-size: 3px 1px; /* First Nr is the GAP width, second Nr is the DOT width */
height: 1px;
}
<article>
<p>Text</p>
<hr>
<p>Text</p>
</article>

Can't move logo position

New to web design, so this is probably really badly written code. This may be something very obvious, but no matter what i change in the css of the logo, i can't get it to move? I need to move the logo down.
.header {
padding: 10px 16px;
background-color: darkred;
box-shadow: 0px 10px 20px black;
font-family: arial;
position: relative;
height: 90px;
}
.logo {
position: absolute;
float: left;
margin-top: 50px;
}
<div class="header" id="myHeader">
<div class="logo">
<img src="https://via.placeholder.com/300x90" width=300 height=90>
</div>
</div>
If you are trying to move the logo somewhere in the website, I think you should not use float, it will attached to somewhere position that you assign them to and because of that you can't move your div freely. You must use top, left, right, bottom. At the same time it will replace margin-top for you. Also you should contain background-repeat: no-repeat, background-size: contain. So your logo won't repeat if you scroll down. And last, you should set margin: 0 auto for they not sticky to other div if you have any.
.logo {
position: absolute;
top: 12px; //For example
background-repeat: no-repeat;
background-size: contain;
margin: 0 auto;
}

Diagonal shape 100% height CSS

Alright, here is the thing. This is what I'm trying to accomplish, which I did so far:
The problem is I use hardcoded pixels right now, but it really needs to be more responsive. So it needs a height of 100% (not 200px like now). And the total width of the diagonal and content containers needs to be 50%, like the image above (so not hardcoded 100px like now). The main problem seems to be the diagonal, cause it almost seems I can only use pixels and not percentages. So if the content block gets more content, it will expand, but the diagonal will not, which is a problem.
It looks like a position absolute could fix it, but then I can't really place the content and diagonal blocks next to each other anymore. Now I gave them two different colors to be clear, but in the live example they need to look like one shape with the same background color.
.shape {
width:400px;
margin:0 auto;
display: block;
height: 200px;
position: relative;
background-image: url('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQdX7yx0pVXUlaNF7WkbSJpZp5r0TflV3WdsojKKK1Xon_1hh08l4OL1yd');
}
.diagonal {
height:0;
border-width: 0px 0 200px 100px;
border-style:solid;
border-color: transparent transparent transparent #d71f55 ;
float: left;
}
.content {
height: 100%;
width: 100px;
background-color: #888;
float: left;
color: #fff;
}
<div class="shape">
<div class="content">
Content goes here
Like this
</div>
<div class="diagonal"></div>
</div>
EDIT:
By the way, I already tried using two backgrounds as well, like:
background-color: #f87f73;
background-image: -webkit-linear-gradient( -28deg, #f87f73 0%, #f87f73 60%, #292423 60%, #292423 60%);
background-image: linear-gradient( -28deg, #f87f73 0%, #f87f73 60%, #292423 60%, #292423 60%);
But that really got ugly. Too pixelated.
Edit 2:
Browser which needs to be supported:
OS: windows 8/10 :
** browsers: Chrome 47/48
** Firefox 43/44
** Internet Explorer 11
OS: mac OSX 10.9/10.10
** Chrome 47/48
** Firefox 43/44
** Safari 8/9
OS: android 5/6
** Chrome latest version
OS: iOS 8/9
** Safari latest version
You can use viewport related units for the border as described in Shape with a slanted side (responsive). This will allow you to make the shape 50% width and 100% height of the viewport and responsive:
* {
margin: 0;
padding: 0;
}
.shape {
width: 100%;
margin: 0 auto;
display: block;
height: 100vh;
position: relative;
background-image: url('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQdX7yx0pVXUlaNF7WkbSJpZp5r0TflV3WdsojKKK1Xon_1hh08l4OL1yd');
}
.diagonal {
height: 0;
border-width: 0 0 100vh 25vw;
border-style: solid;
border-color: transparent transparent transparent #d71f55;
float: left;
}
.content {
height: 100vh;
width: 25vw;
background-color: #888;
float: left;
color: #fff;
}
<div class="shape">
<div class="content">
Content goes here Like this
</div>
<div class="diagonal"></div>
</div>
Viewport related units (vh and vw) have good browser support. For more info, see canIuse
This is probably how I would approach it. Using a hard 50/50 gradient rather than a border makes it pretty trivial. It seems to render ok in chrome but I haven't checked other browsers. If you want this inside a container remember to set the container to position: relative
.shape {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: auto;
height: auto;
display: block;
background-image: url('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQdX7yx0pVXUlaNF7WkbSJpZp5r0TflV3WdsojKKK1Xon_1hh08l4OL1yd');
}
.content {
height: 100%;
width: 25%;
background-color: #888;
color: #fff;
float: left;
}
.diagonal {
height: 100%;
width: 25%;
background: linear-gradient(to bottom right, #888 50%, transparent 50%);
float: left;
border: none;
}
<div class="shape">
<div class="content">
Content goes here Like this
</div>
<div class="diagonal"></div>
</div>

background-size: contain too much whitespace when changing browser size

How do I eliminate the whitespace when the browser size changes if I am using background-size:contain;?
The whitespace between the image and the text is way too much with smaller browser sizes. site is: http://16debut.com/test.html
CSS is:
body {
margin:0px 0px;
}
#hero {
background-clip: content-box;
background-image: url("imgtop.png");
background-size: contain;
background-repeat: no-repeat;
position: relative;
height: 235vh;
}
#content {
padding: 100px 50px;
text-align: center;
width: 80%;
margin: 0px auto;
}
#content h2 {
margin: 0px 0px 30px 0px;
}
#footer {
padding: 30px 0px;
text-align: center;
background: #ddd;
}
jsbin demo
You want to go fully responsive but keep the white clouds at the bottom?
Use two background images for the same element.
Cut out the white bottom clouds save as separate .png image. Use as first background-image.
(optional) Save again your bigger image, just without the white clouds. Use that image as second background image value.
Now in CSS:
set the clouds to background-position: bottom and 100% size ("width")
Set the bigger image to center (50%) position and cover
CSS
html, body{height:100%; margin:0;}
#hero{
position:relative;
height:130vh; /* USE THE RIGHT RATIO since the image Logo is a bit up*/
background: no-repeat
url(http://i.stack.imgur.com/eWFn6.png) bottom / 100%, /* BOTTOM CLOUDS OVERLAY */
url(http://i.stack.imgur.com/IVgpV.png) 50% / cover; /* BIG IMAGE */
}
HTML
<div id="hero"></div>
<div class="other">
<h1>Other Divs</h1>
<p>bla bla</p>
</div>
Seems that Safari is a quite stupid browser (they even removed support for windows since 2012... Amazing). Here's the jsBin example and css:
#hero{
position:relative;
height: 900px;
height: 100vh;
background: url(http://i.stack.imgur.com/eWFn6.png) no-repeat bottom, url(http://i.stack.imgur.com/IVgpV.png) 50%;
background-size: 100%, cover;
}