div not obeying height - html

I'm trying to create an element with a div in it, the div is a slightly smaller box then the outer, and makes it appear as a border withing the outer box.. hard to verbalize. the div contains several ul's that I want to maintain a height of 64px, and I want the div to have a set height also. however, the div seems unresponsive to any height I set in css, it just wants to do its own thing I guess and instead has decided that it should base its height on how many ul's there are within it.. I was hoping someone could explain whats going on with it, why it wont obey my commands, and possibly offer a solution.
here's the css:
#selectUnitScreen {
overflow: hidden;
min-width:390;
min-height:350;
left:5%;
top:5%;
bottom:5%;
right:5%;
padding:5%;
border-left: solid red 5px;
border-right:solid red 5px;
border-top: solid red 12px;
border-bottom: solid red 12px;
}
#selectUnitScreen ul {
height:64px;
}
#selectUnitScreen li {
font-size:25px;
padding-left: 5%;
display: inline-block;
}
#buildUnitScreen {
padding: 3px;
position: absolute;
z-index: 10;
border-radius: 2%;
border: 3px solid black;
width:400px;
height:470px;
background: white;
box-shadow: 4px 0px 2px 1px black;
left:260px;
top:200px;
}
and the HTML:
<section id="buildUnitScreen">
<div id="selectUnitScreen">
<ul id="build">
<li class="name">
infantry
</li>
<li class="cost">
1000
</li>
</ul>
<ul id="build">
<li class="name">
mechenized infantry
</li>
<li class="cost">
3000
</li>
</ul>
</div>
jsfiddle: https://jsfiddle.net/FJV8b/

The problem lies in your not setting units for the min-height and min-width. You say 390 and 350 but what are those? px? Otherwise those values are ignored. So:
min-height:350px;

Related

Fit text into flexbox container

I have a navigation bar with image in the middle. Looks similar to this:
<nav class="navigation">
<ul class="navigation-list-1">
<li class="navigation-list-item">Home</li>
<li class="navigation-list-item">Features</li>
<li class="navigation-list-item">Add info</li>
<li class="navigation-list-item"><img class="logo" src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg?v=6f4af2d2d158"></li>
<li class="navigation-list-item">Form</li>
<li class="navigation-list-item">Team</li>
<li class="navigation-list-item">Contact</li>
</ul>
And style:
> .navigation-list-item {
list-style: none;
font-size: 15px;
font-weight: bold;
}
.logo {
position:absolute;
width: 10vw;
left:calc(50% - (10vw/2) - (10px/2));
background: cornflowerblue;
border: 5px solid cornflowerblue;
}
ul{
display:flex;
margin-left:-40px;
}
li{
flex:1;
background:yellow;
border:1px solid green;
height:70px;
line-height:70px;
text-align:center;
}
li>a{
text-decoration:none;
}
Now, if text in navigation item is longer than particular length, the text is spliting into next line and going outside the bar so it doesn't look good. How to make text in container always to be in one line?
Good option for start is to add css style for text: white-space: nowrap;
Another good way is to set the font-size in vw units. Font will be responsive depending on screen size.

Funnel chart in css

I am trying to customize a funnel chart on the basis of data that I have rendered through database on page.
All works well except css rendering for chart.
<ul id="funnel-cht">
<li style="height:70px;width:50%;background-color:yellow">pendora</li>
<li style="height:70px;width:40%;background-color:#98bf26">pending</li>
<li style="height:70px;width:30%;background-color:orange">pen</li>
<li style="height:70px;width:20%;background-color:#c10000">Test</li>
</ul>
Here is what it looks like right now-
http://jsfiddle.net/m74ets8v/1/
I want to style it according to actual looking funnel chart, for an example-
How would i be styling this chart to make sense for me.
.funnel_outer{width:420px;float: left;position: relative;padding:0 10%;}
.funnel_outer *{box-sizing:border-box}
.funnel_outer ul{margin:0;padding:0;}
.funnel_outer ul li{float: left;position: relative;margin:2px 0;height: 50px;clear: both;text-align: center;width:100%;list-style:none}
.funnel_outer li span{ border-top-width: 50px;border-top-style: solid; border-left: 25px solid transparent; border-right:25px solid transparent; height: 0;display: inline-block;vertical-align: middle; }
.funnel_step_1 span{width:100%;border-top-color: #8080b6;}
.funnel_step_2 span{width:calc(100% - 50px);border-top-color: #669966}
.funnel_step_3 span{width:calc(100% - 100px);border-top-color: #a27417}
.funnel_step_4 span{width:calc(100% - 150px);border-top-color: #ff66cc}
.funnel_step_5 span{width:calc(100% - 200px);border-top-color: #0099ff}
.funnel_step_6 span{width:calc(100% - 250px);border-top-color: #027002}
.funnel_step_7 span{width:calc(100% - 300px);border-top-color: #ff0000;}
.funnel_outer ul li:last-child span{border-left: 0;border-right: 0;border-top-width: 40px;}
.funnel_outer ul li.not_last span{border-left: 5px solid transparent;border-right:5px solid transparent;border-top-width:50px;}
.funnel_outer ul li span p{margin-top: -30px;color:#fff;font-weight: bold;text-align: center;}
<div class="funnel_outer">
<ul>
<li class="funnel_step_1"><span><p>1</p></span></li>
<li class="funnel_step_2"><span><p>2</p></span> </li>
<li class="funnel_step_3"><span><p>3</p></span></li>
<li class="funnel_step_4"><span><p>4</p></span></li>
<li class="funnel_step_5"><span><p>5</p></span></li>
<li class="funnel_step_6"><span><p>6</p></span></li>
<li class="funnel_step_7"><span><p>7</p></span></li>
</ul>
</div>
The secret is to use margin: 0 auto for the lis. Setting the automatic margin calculation for the left/right dimension will center a block element horizontally. (Unfortunately, this technique doesn't work for vertical centering, but that's a different story.)
Here's your code, slightly modified, in a working example:
ul, li { margin: 0; padding: 0; list-style: none; }
ul { width: 400px; }
li { height: 70px; margin: 0 auto; }
/* NOTE: nth-child would be the better way to assign CSS to a set of
uniform elements than one class per li, but let's keep it simple for now */
li.li1 { width: 50%; background-color: yellow; }
li.li2 { width: 40%; background-color: #98bf26; }
li.li3 { width: 30%; background-color: orange; }
li.li4 { width: 20%; background-color: #c10000; }
<ul>
<li class='li1'>pendora</li>
<li class='li2'>pending</li>
<li class='li3'>pen</li>
<li class='li4'>Test</li>
</ul>
By the way, as already noted in the comments: In order to have actual trapezoids, you would (as far as I know) need to use SVG, and of course appropriate fallbacks for browser that don't support it.
If, as i read from comments, you just need to center the <li> elements you can set the an auto margin.
#funnel-cht>li
{
display:block;
margin:0 auto;
}

How to put text on the center of a circle using CSS

I am new to HTML, I have created circle using border-radius and i have put some text in it. the Text is displaying on the lower part of the Box and its also appearing after the circle. I want to put the Text in the circle.
Kindly check this and guide me.
<ul>
<li>HOME</li>
<li id="skills" class="navText" >Work - Work Experience</li>
<li id="web" class="navText">Skills </li>
<li id="video1" class="navText">Web - Web Projects </li>
<li id="video2" class="navText">Video - Video Projects </li>
</ul>
Style
#navText
{
position:absolute;
top:-90px;
}
nav ul
{
list-style-type:none;
padding:0;
margin:20px 0px 0px 130px;
}
nav ul #skills
{
position:absolute;
line-height:-200px;
background-color:#EA7079;
display: inline-block;
border:6px solid;
border-color:white;
border-radius:110px;
padding: 91px 31px 31px ;
width:80;
height:25;
text-align:center;
#margin-left:35px;
}
Line-height equal to height of the div/li also works - FIDDLE
This works fine for short lines, for long lines, you'll have to use another technique as mentioned.
The top circle in the fiddle is a div in a div changed to inline-block
CSS
.centerofcircle1 {
width: 100px;
height: 100px;
border-radius: 50%;
line-height: 100px;
font-size: 15px;
background-color: red;
color: white;
text-align: center;
}
This is one of the thing that css dosen't do very well. However there is a solution, here is a great article by Chris Coyier that helped me with this problem.
You could add the vertical-align property to your text class.
vertical-align: middle;
Also, if that doesn't work, try to manually place in the middle with margin-bottom or/and margin-top.
margin-bottom: 10px;
And your #navText is an id. Use div id="navText" instead of class="navText"

CSS: correct way to make thick <a:hover> underline for fonts with big descenders

I'm a CSS-beginner. Basically I have the following html:
<ul>
<li>О нас</li>
<li>Галерея</li>
</ul>
I want to have a thick underline when hovering my a tags, but I use a custom font with big descenders, so if I use the common trick for this:
a:hover {
text-decoration: none;
border-bottom: 2px solid;
padding: 0;
margin: 0;
}
The underline is far below the base line: But I want it to look like this:
I tried to do it like this:
<ul>
<li class="over">О нас</li>
<li class="over">Галерея</li>
</ul>
.over{
font-size: 30px;
height:30px; // makes the text overlap this element
overflow:visible;
}
.over:hover {
border-bottom: 2px solid #ec6713;
}
But the width of the underline is the same for all the strings now:
Then I added display: inline-block; for .over. But I got this:
Then I changed inline-block to table, but the underline is again far below:
I ended up adding an extra span, so now I have:
<ul>
<li><span class="over">О нас</span></li>
<li><span class="over">Галерея</span></li>
</ul>
.over{
font-size: 30px;
height:30px; // makes the text overlap this element
overflow:visible;
display:inline-block;
}
.over:hover {
border-bottom: 2px solid #ec6713;
}
And this gives me finally the desired behaviour (the underline width is adjusted to the string width, and it's positioned close to the baseline). But is it a good practice to add an extra span for this purpose? Doesn't it look hacky?
A span is a meaningless tag, so it won't give extra 'weight' to your code. Therefor, imho, it is okay to use it (but better to avoid).
Alternatively you could do the following:
<ul>
<li>О нас</li>
<li>Галерея</li>
</ul>
a {
font-size: 30px;
text-decoration: none;
position: relative;
}
a:hover:after {
content: "";
border-bottom: 2px solid #ec6713;
position: absolute;
left: 0;
right: 0;
bottom: 3px;
}
And a DEMO.
Please note that the :after is overlapping the a. I've tried adding a z-index, but that didn't fix it.
OPTION 2
Add a background-image to your a.

remove top border

I have two DIVs one contain new release and must, another one contain whole data.
both div have a red border. I remove bottom border of first div.
I want to remove the border where I marked with red rectangle:
Have your active tab have position:relative and z-index higher then the content box. Then add border-bottom: 1px solid white and give it margin-bottom: -1px.
From a current project: http://jsfiddle.net/aVZLH/1/
Maybe you have some additional work for IE. But rudimentary it should show you a way to solve your problem... Without additioanl markup in your document.
<ul>
<li class="current">Tab #1</li>
<li>Tab #2</li>
</ul>
<div class="content">
<p>MY AWESOME CONTENT</p>
</div>
/*CSS*/
ul {
overflow: hidden;
position: relative;
top: 1px;
z-index: 2;
}
li {
color:#fff;
background:red;
float:left;
border:1px solid red;
padding:5px 10px;
position:relative;
top:1px;
}
.current {
background: #FFFFFF;
border-bottom: 0;
color: red;
}
.content {
padding:20px;
border:1px solid red;
position:relative;
z-index:1;
}
You can create another div to occupy the space to the right of the "Must" tab. Set this div's bottom border to "1px solid red". Then, remove the border-top from the news box, and the border-bottom from the tabs themselves.