I'm new at CSS and am going through tutorials, etc. All good – but I'm stuck on the little design below. I am trying to make the layout ignore the horizontal box with the timestamp and I've tried everything – float, position absolute, relative, margins, etc. and at this point I am just throwing tags in without having a clue.
What I am trying to accomplish is for the vertical red box - the "leader line" to connect to the large box below through ignoring the "timestamp" box. Maybe I have structured my HTML poorly and that is making it harder for me to accomplish this?
This is probably pretty simple. I've also been wrestling with the uneven margin around the image but that's less important.
The "Leader line" is of the "vAxis" class. The "timeStamp" block is of the "timeLabel" class.
I made a codePen if the snippet below isn't clear.
Update:
I just realized that I don't have to try to ignore the div with the timestamp. I can just make it use a border-left to continue to draw the vertical. Don't know if that means I am clever, hacky or just getting with the "CSS" way of thinking. The reason I couldn't use absolute is because I want to use this code for multiple components in a Vis.js timeline – and their vertical positions will vary.
I've updated the codepen
Original issue:
body {
background-color: #000;
}
.hAxis {
width: 100%;
height: 10px;
border-bottom: 4px solid #ffffff;
}
.outsideDiv {
position: absolute;
left: 220px;
}
.vAxis {
width: 50px;
height: 100px;
outline: 1px solid red;
border-left: 6px solid rgba(255, 255, 255, .5);
;
}
.box-4 {
background-color: #011c21;
background: -webkit-linear-gradient(90deg, #1A333D 0%, #030506 100%);
border: 6px solid rgba(255, 255, 255, .5);
width: 330px;
padding: 6px;
}
.box-4:hover {
border: 6px solid rgb(255, 255, 255);
}
.box-4:active {
border: 6px solid rgb(255, 255, 0);
}
.imageDiv {
box-align: center;
display: inline-block;
margin-left: 5px;
margin-right: auto;
}
img {
outline: 1px solid #000;
}
.timeLabel {
color: #D0D1D9;
background: transparent;
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
font-weight: bold;
margin-bottom: 2px;
text-align: right;
text-shadow: rgb(13, 52, 181) 6px 6px 10px;
outline: 1px solid red;
margin-left: 100px;
width: 250px;
}
.narrative {
color: #cccccc;
font-size: 24px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
width: 300px;
position: relative;
padding: 10px;
/* text-shadow: rgb(77, 100, 176) 0px 2px 2px; */
}
html {
height: 100%;
}
body {
background-color: #0e1c21;
/* IE9, iOS 3.2+ */
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0idnNnZyIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMCUiIHkyPSIxMDAlIj48c3RvcCBzdG9wLWNvbG9yPSIjMDAwMDAwIiBzdG9wLW9wYWNpdHk9IjEiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiMxYzM3NDIiIHN0b3Atb3BhY2l0eT0iMSIgb2Zmc2V0PSIxIi8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI3ZzZ2cpIiAvPjwvc3ZnPg==);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0, rgb(0, 0, 0)), color-stop(1, rgb(28, 55, 66)));
/* Android 2.3 */
background-image: -webkit-linear-gradient(top, rgb(0, 0, 0) 0%, rgb(28, 55, 66) 100%);
/* IE10+ */
background-image: linear-gradient(to bottom, rgb(0, 0, 0) 0%, rgb(28, 55, 66) 100%);
}
}
<div class="hAxis"></div>
<div class="outsideDiv">
<div class="vAxis"></div>
<div class="timeLabel">04:35:27</div>
<div class="box-4">
<div class="imageDiv">
<img src="http://placehold.it/320x240/0000ff/000000" width='320' height='240' />
</div>
</div>
<div class="narrative">Cras sit amet maximus at libero, at vehicula justo. Cras sit amet maximus libero, at.
</div>
</div>
In your codepen demo, the red vertical box is already touching the blue box below. So I guess you solved that already.
With regard to the uneven margins around the image, there are several factors in play:
(1) You have set a width on an ancestor container that makes it longer than the image:
.box-4 {
background-color: #011c21;
background: -webkit-linear-gradient(90deg, #1A333D 0%, #030506 100%);
border: 6px solid rgba(255, 255, 255, .5);
width: 330px; <--- REMOVE THIS
padding: 6px;
}
(2) You have set uneven margins on the immediate container. Even them out.
.imageDiv {
box-align: center;
display: inline-block;
margin-left: 5px; <--- REMOVE THIS, AND..
margin-right: auto; <--- THIS
margin: 5px; <-- NEW
}
(3) An image is an inline-level element, so it has vertical-align: baseline set by default. This elevates it within the container. Override the default:
img {
outline: 1px solid #000;
vertical-align: bottom; <--- NEW
}
revised codepen
adding position:absolute can solve the problem by overlaying the timelabel on the box4
But Try
margin-top:-42px;
in the timelabel class, maybe this is the answer you needed :)
Add display: none to .vAxis This hides this DIV completely (I suppose that's what you mean by "ignore"?)
http://codepen.io/anon/pen/JEOwVo?editors=1100
Related
I want to create a navbar with a transparent background and also hide the text underneath when I scroll. I want an overflow hidden but I cant get it to work. This is very specific because I have a linear-gradient with a rotation of 60% hence I cant just use the same background!
I have provided a Codepen replicating the problem down below.
HTML Code
<nav>
<h2>Logo</h2>
</nav>
<div class="pageContainer">
<p>Some test text that I want to be hidden under the navbar when I scroll!</p>
</div>
CSS code
* {
margin: 0;
padding: 0;
color: white;
font-family: sans-serif
}
body {
background: linear-gradient(60deg, rgba(84, 58, 183, 1) 0%, rgba(0, 172, 193, 1) 100%);
}
nav {
box-shadow: rgba(0, 0, 0, 0.25) 0px 5px 10px;
width: 100%;
height: 100px;
position: fixed;
top: 0;
display:flex;
align-items: center;
padding: 0 20px;
}
.pageContainer {
height: 200vh;
margin-top: 150px;
padding: 0 20px;
}
https://codepen.io/Forsrobin/pen/ZExRyMa
I was wondering if anyone could point in the direction of a solution!
For some reason my rightbar's height isn't staying within the parent div (mainwrapper), and I have the body and the wrapper's height set to 100%.
When I set it to 90% it fits but then when I resize the window to anything lower than 1920x1080, it goes out of the wrapper again.
Any and all would be appreciated!
I read online somewhere that it's usually floating divs that cause this, but I have nothing floating and I believe I have the corrent position:relative placed.
I've not worded this the best with "bar", so here's a gyazo image to hopefully help with this: https://gyazo.com/6661da9c5194e2c2619e5fe1b5e3f2c5 - As you can see, the bar goes out of the wrapper when set to 100%
My code:
body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background-image: url(/css/images/backgroundimages/bgimg.png);
}
div#mainwrapper {
width: 80%;
height: 100%;
margin-left: auto;
margin-right: auto;
border-left: 4px solid #000;
border-right: 4px solid #000;
box-shadow: 0px 0px 10px #000;
background-color: rgba(0, 0, 0, 0.6);
}
div#menubar {
background-color: rgba(41, 128, 185, 0.2);
text-align: center;
padding: 30px;
border-bottom: 3px solid #000;
}
div#menubar a {
text-align: center;
padding: 31px;
text-decoration: none;
color: rgba(255, 255, 255, 1);
transition: 0.3s;
font-size: 1.1em;
font-family: 'Muli', sans-serif;
text-shadow: 2px 4px 7px #000;
}
div#menubar a:hover {
background-color: rgba(0, 0, 0, 0.4);
padding: 30px;
font-size: 1.3em;
transition: 0.3s;
color: rgba(231, 76, 60, 1.0);
text-shadow: 1px 1px 2px #000;
font-weight: bold;
border-right: 2px solid #000;
border-left: 2px solid #000;
}
div#maincontent {
width: 100%;
height: 100%;
}
div#rightbar {
width: 15%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
}
<div id="mainwrapper">
<div id="menubar">
HOME
FRIENDS
FORUM
CONTACT
</div>
<div id="maincontent">
<div id="rightbar">
</div>
</div>
</div>
EDIT: Try erasing the height: 100%; on div#rightbar and replace it with min-height: calc(100vh - 85px);
The reasoning: 100vh means '100% viewport height'. So whatever the height of your browser window is the height #rightbar will be. But you need to subtract the height of #menubar from it (85px). calc() helps you accomplish this. Take a note of this css property/value combo because you'll potentially use it a lot for making your footers stick to the bottom of the page (AKA 'sticky footers'). Make sure you have a space on either side of the - sign. If you don't include those spaces, the calc() function won't work.
OLD ANSWER: I apologize if I don't understand what you're wanting, but I'll give it a shot: #rightbar's height actually is inside of the wrapper - it's just not inside the border that you created around #menubar.
Erase border-bottom: 4px solid #000; from div#menubar and move it to div#mainwrapper instead. Here's an example: https://jsfiddle.net/ms2e2e5v/1/
I am trying to get a certain effect on a header for a mockup. It has white glow almost not noticeable. You will see it in this picture i provide behind the title and sub title. How can i get that glow effect with css? I do have a header with the entire thing but is that a good idea to use an image for an entire header? Also i want those two lines near the subtitle. Is it possible to code those lines? And last, the button "order now", will that be possible to make with css or should i just use an image of that and link it?
mockup
jsfiddle - http://jsfiddle.net/ezdr3xdg/1/ [what i currently have]
<header>
<h1>Taffies Cupcakes</h1>
<h2>Fresh and tasty</h2>
</header>
body{
background-color:#e7d2c9;
}
header h1{
font-family:georgia;
font-size:46px;
color:#784f3d;
text-align:center;
margin-top:50px;
}
header h2{
font-family:segoe script;
font-size:32px;
color:#846a5f;
text-align:center;
}
All of this is possible to do in CSS 3, I wouldn't recommend it though. Using an image for the button and the header is the best idea if you want it to look the same in all browsers. If you want to do it in CSS anyway try this:
HTML:
<header>
<div class="shadow"></div>
<h1>Taffies Cupcakes</h1>
<h2><div class="line"></div>Fresh and tasty<div class="line"></div></h2>
</header>
CSS:
header > .shadow {
width: 0px;
height: 0px;
margin: 0px 50%;
box-shadow: 0px 0px 200px 100px white;
}
header h2 > .line {
height: 1px;
width: 100px;
margin: 5px 20px;
background-color: #846a5f;
display: inline-block;
vertical-align: middle;
}
As the other answers have mentioned, radial-gradient is probably the way to go here. Just apply it to the header element instead of using my version with box-shadow (which might be a little hacky to some).
Update for the button:
HTML:
<button class="special"><div class="icon"></div><div class="headline">ORDER NOW</div><div class="description">We deliver in 24 hours</div></button>
CSS:
button.special {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #784f3d), color-stop(1, #846a5f) );
background:-moz-linear-gradient( center top, #784f3d 5%, #846a5f 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#784f3d', endColorstr='#846a5f');
background-color:#784f3d;
color: #e7d2c9;
text-align: left;
border: 0;
outline: 0;
border-radius: 5px;
height: 42px;
}
button.special > .icon {
width: 27px;
height: 27px;
/*background-image: url('triangle-button.png')*/
position: absolute;
margin: 5px;
}
button.special > .headline {
margin-left: 42px;
font-size: 18px;
}
button.special > .description {
margin-left: 42px;
font-size: 12px;
}
http://jsfiddle.net/ezdr3xdg/17/
Use CSS radial-gradient()
DEMO 1:
body {
height: 100vh;
background-color: #e7d2c9;
background-image: -webkit-radial-gradient(center top, ellipse farthest-corner, #fff 0%, #e7d2c9 50%);
}
DEMO 2:
body{
height:100vh;
background-color:#e7d2c9;
background-image: -webkit-radial-gradient(center top, ellipse farthest-corner, #fff 0%, #e7d2c9 100%);
}
DEMO 3:
body {
height: 100vh;
background-color: #e7d2c9;
position:relative;
}
body:after {
content: '';
position: absolute;
left: 50%;
top: -150px;
margin-left: -100px;
width: 200px;
height: 200px;
border-radius: 50%;
z-index:-1;
background: rgba(255, 255, 255, 0.42);
box-shadow: 0 0 40px 64px rgba(255, 255, 255, 0.42);
}
I have update your jsfiddle with a starting template of sorts. Its CSS# gradients and border-radius. http://jsfiddle.net/ezdr3xdg/7/
the button:
<div id="order_now">
<div id="triangle-right"></div>
<div id="text">
ORDER NOW
<div id="sub_order">we deliver in 24hours</div>
</div>
</div>
CSS:
The Button:
#order_now{
background: linear-gradient(#846a5f, brown);
width: 200px;
border-radius: 5px;
padding: 5px;
color: white;
font-size: 12pt;
font-weight: bold;
}
#sub_order{
font-size: 10pt;
font-style: italic;
}
#triangle-right {
width: 0;
height: 0;
border-top: 25px solid transparent;
border-left: 50px solid white;
border-bottom: 25px solid transparent;
display: inline-block;
}
#text{
display: inline-block;
}
The Background:
body{
background:linear-gradient(to right, red, blue, red);
}
this should be enough to get you started.
How would one extend this pagination to be full width? I'm struggling.
Example code: http://cssdeck.com/labs/cxdkfkjv
Thanks
This is the CSS code:
.pagination {
text-align: justify;
background: #f2f2f2;
padding: 20px;
margin-bottom: 20px;
}
.page {
display: inline-block;
padding: 0px 9px;
margin-right: 3px;
border-radius: 3px;
border: solid 1px #c0c0c0;
background: #e9e9e9;
box-shadow: inset 0px 1px 0px rgba(255,255,255, .8), 0px 1px 3px rgba(0,0,0, .1);
font-size: .875em;
font-weight: bold;
text-decoration: none;
color: #717171;
text-shadow: 0px 1px 0px rgba(255,255,255, 1);
}
.page:hover, .page.gradient:hover {
background: #fefefe;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FEFEFE), to(#f0f0f0));
background: -moz-linear-gradient(0% 0% 270deg,#FEFEFE, #f0f0f0);
}
.page.active {
border: none;
background: #616161;
box-shadow: inset 0px 0px 8px rgba(0,0,0, .5), 0px 1px 0px rgba(255,255,255, .8);
color: #f0f0f0;
text-shadow: 0px 0px 3px rgba(0,0,0, .5);
}
.page.gradient {
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f8f8f8), to(#e9e9e9));
background: -moz-linear-gradient(0% 0% 270deg,#f8f8f8, #e9e9e9);
}
The HTML part comes in here
<div class="pagination">
<p>How can I extend (justify) this pagination to the full width of the div "pagination"?</p>
first<a href=
"#" class="page gradient">2</a><a href="#" class=
"page gradient">3</a><span class=
"page active">4</span><a href="#" class=
"page gradient">5</a><a href="#" class=
"page gradient">6</a><a href="#" class=
"page gradient">last</a>
</div>
In your given markup, the child elements of pagination have no whitespace between them.
So firstly, make sure there is a whitespace in your markup between the child elements. Without this there's no way text-align:justify will work.
(Just like when you want to justify text, it won't work unless you have spaces between your words!)
Next, add a pseudo element after the pagination element with 100% width.
Updated DEMO
..or for those who prefer a FIDDLE :)
.pagination:after
{
content: '';
width: 100%;
display: inline-block;
}
Are you loocking for this?
Set your .pagination to display: table; and them your .page to table-cell.
Not sure what you want to do, if only center in the middle Anup just answered how to, but if you want to extend evenly all buttons, you can try and use display: table;
http://cssdeck.com/labs/krdfmoeh
I'm not sure if there's an automatic way to do this. What you could do is something like this:
.pagination {
text-align:center;
}
.page {
width:6%;
margin:0 3.9%;
}
Remove the padding from .page or add * { box-sizing:border-box; }.
If you want the first and left buttons to have to margin on the outside, give them "first" and "left" classes and do:
.page {
width:6%;
margin:0 4.5%;
}
.page.first { margin-left:0; }
.page.last { margin-right:0; }
See: http://cssdeck.com/labs/yfuud0le
Note that if you add more pagination items you have to manually edit the width and margin of the .page div.
Center will look nice for you.
.pagination {
text-align: center;
}
I have a box container as shown bellow
Which i want to code in a modular way so that i can use the html css structure to build any size box in width and height. I will be using Bootstrap to code the website
Which is the best way to get started.
Let's say that gradient on the top is named gradient.png
.box {
border: 1px solid gray;
border-radius: 3px;
background: white url("gradient.png") ;
background-repeat: repeat-y;
padding-top: 20px;
}
I think it's mostly self explanatory; the repeat-y just makes it repeat accross the top but not throughout the rest of the image. The padding makes it so the text doesn't start at the top. See how it works for you.
By the way, is that from the Apple discusion page?
I tried to keep this as similar to your example as I could with straight CSS. Given this approach, you won't find immediate support in IE8 and lower.
The markup for the box itself is pretty simple:
<div id="modal">
<header><h1>Something Here</h1></header>
<section>
<p>Pellentesque habitant morbi tristique...</p>
</section>
</div>
The CSS for this markup can be found below the preview image below.
Demo: http://jsbin.com/ogesuf/5/edit
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
#modal {
width: 600px;
border: 1px solid #CCC;
box-shadow: 0 1px 5px #CCC;
border-radius: 5px;
font-family: verdana;
margin: 25px auto;
overflow: hidden;
}
#modal header {
background: #f1f1f1;
background-image: -webkit-linear-gradient( top, #f1f1f1, #CCC );
background-image: -ms-linear-gradient( top, #f1f1f1, #CCC );
background-image: -moz-linear-gradient( top, #f1f1f1, #CCC );
background-image: -o-linear-gradient( top, #f1f1f1, #CCC );
box-shadow: 0 1px 2px #888;
padding: 10px;
}
#modal h1 {
padding: 0;
margin: 0;
font-size: 16px;
font-weight: normal;
text-shadow: 0 1px 2px white;
color: #888;
text-align: center;
}
#modal section {
padding: 10px 30px;
font-size: 12px;
line-height: 175%;
color: #333;
}
</style>
If you're willing to try jQuery ui you can simply use dialog to achieve what you want here is the link with more info.
http://jqueryui.com/demos/dialog/#default