How to prevent CSS block elements from affecting parent inline-blocks - html

I am having an issue with elements inside an inline-block parent. The child elements of one are affecting the other. It is tough to explain but it is easy to see in my fiddle, that the div on the right is being pushed down.
I have tried various things, but I am sure there is a simple solution. Any advice is appreciated.
http://jsfiddle.net/62asy/
HTML:
<div id="schedule">
<div class="scheduleChoice">Leagues
<select name="leagueList" id="leagueList" class="scheduleChoiceList">
<option value="0">Select a League</option>
<option value="leagueId_246"> Aassss</option>
<option value="leagueId_245"> aaa</option>
</select>
<select name="teamList" id="teamList" class="scheduleChoiceList">
</select>
<div class="scheduleChoiceSubmit">Submit</div>
</div>
<div class="scheduleChoice">Arena
<select name="arenaList" id="arenaList" class="scheduleChoiceList">
<option value="0">Select an Arena</option>
<option value="arenaId_2"> ffffff</option>
<option value="arenaId_1"> ffffff</option>
</select>
<div class="scheduleChoiceSubmit">Submit</div>
</div>
</div>
CSS:
#schedule {
background-color: rgba(0, 0, 0, 0.44);
overflow: hidden;
text-align: center;
}
.scheduleChoice {
display: inline-block;
width: 25%;
background-color: rgba(190, 216, 255, 0.54);
height: 200px;
padding: 5px;
border-radius: 5px;
margin: 20px 25px;
}
.scheduleChoiceList {
width: 200px;
padding: 5px;
border-radius: 4px;
display: block;
margin: 10px auto;
}

Add vertical align top
.scheduleChoice {
vertical-align: top;
}
Edited fiddle
http://jsfiddle.net/62asy/1/

Related

Browser zoom is causing weird behavior select box

I got a question regarding browser zoom and my select box. I have created a custom select box with the current HTML and CSS code (JSFIDDLE):
.custom-select {
position: relative;
width: 100px;
display: inline-block;
}
.custom-select select {
width: 100%;
padding: 8px 5px 8px 10px;
height: 36px;
border: 1px solid #cacaca;
color: #0085c8;
}
.custom-select.svg > svg.dropdown-button {
position: absolute;
top: 0;
right: 0;
width: 34px;
height: 34px;
background-color: #fff;
background-image: url(https://cdn0.iconfinder.com/data/icons/solid-line-essential-ui-icon-set/512/essential_set_down-16.png);
background-repeat: no-repeat;
background-position: center;
pointer-events: none;
border: 1px solid #cacaca;
color: #0085c8;
display: inline-block;
}
<div class="custom-select svg">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="Volkswagon Polo">Volkswagon Polo</option>
</select>
<svg class="dropdown-button"></svg>
</div>
Whenever you scale down your browser to for example 75% I get the following situation:
Where the word POLO is cutoff. What am I doing wrong? This should not be zooming sensitive right? Can you set CSS styling to specific zoom levels?
--EDIT
Increasing the width is not an option due to the fact that the select is been placed inside a div with a maximum width of 150px
You can try with giving auto width to your custom select box.
.custom-select
{
position: relative;
width:100px;
display:inline-block;
overflow:hidden
}
.custom-select select{
width:auto;
padding: 8px 5px 8px 10px;
height:36px;
border: 1px solid #cacaca;
color: #0085c8;
}
.custom-select.svg > svg.dropdown-button
{
position: absolute;
top: 0;
right: 0;
width: 34px;
height: 34px;
background-color: #fff;
background-image: url(https://cdn0.iconfinder.com/data/icons/solid-line-essential-ui-icon-set/512/essential_set_down-16.png);
background-repeat:no-repeat;
background-position:center;
pointer-events: none;
border: 1px solid #cacaca;
color: #0085c8;
display:inline-block;
}
<div class="custom-select svg">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="Volkswagon Polo">Volkswagon Polo</option>
</select>
<svg class="dropdown-button"></svg>
</div>

`Position: relative` is being ignored?

in my test page, I am using Screenfly to check resolution, and it seems my "social login" and my "province selector" are scrolling, despite having overflow: hidden and position: relative. for the loginText class (social media) it's being called from some other document that I do not have access to.
my testing page: Screenfly Test
Html:
<div class="hideFrench">Français</div>
<div class="styled-select">
<select id="provinceSelect">
<option>Please select a province</option>
<option value="alberta">Alberta</option>
<option value="bc">British Columbia</option>
<option value="Manitoba">Manitoba</option>
<option value="NB">New Brunswick</option>
<option value="NF">Newfoundland and Labrador</option>
<option value="Ns">Nova Scotia</option>
<option value="Nunavut">Nunavut</option>
<option value="ON" selected="selected">Ontario</option>
<option value="PEI">Prince Edward Island</option>
<option value="Quebec">Quebec</option>
<option value="Saskatchewan">Saskatchewan</option>
</select>
</div>
<div class="loginText" >
<a class="janrainEngage loginHref" href="#">Or login with
<span class="janrain-provider-icon-16 janrain-provider-icon-facebook"></span>
<span class="janrain-provider-icon-16 janrain-provider-icon-linkedin"></span>
<span class="janrain-provider-icon-16 janrain-provider-icon-twitter"></span>
</a>
</div>
CSS:
.loginText{
position: relative !important;
left: 600px;
top: -125px;
overflow: hidden;
}
.styled-select {
width: 185px;
position: relative;
left: 933px;
top: 40px;
background: rgba(0, 0, 0, 0) url("http://convio.cancer.ca/mResponsive/images/icons/dropdown_blue_icon.png") no-repeat scroll right center;
border: 1px solid #e9e9e9;
overflow: hidden;
}
.styled-select select {
background: transparent;
width: 268px;
padding: 5px;
font-size: 13px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;
}
.hideFrench {
position: relative;
top: 70px;
left: 875px;
border: 2px
}
#media screen and (max-width: 768px){
.styled-select, .hideFrench{
display: none;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
}
It originally was working properly for the last few days, but since then I've made a lot of changes, and now I have no clue what's causing it to stay fixed and where that big white gap is coming from between the login and the province selector.
Any help is greatly appreciated, thank you for your time!
.loginText {
position: absolute;
top: 60px;
right: 18px;
overflow: hidden;
}

Having css issues div ahref showing up behind others, domino effect

I have a href button that I styled to have a blue padded border.
Here is how it looks.
It is stacking behind the header and the search bar and I cant figure out why.
If anyone can help me out. here is the html code of the 3 divs.
<div id="topnav">
<span>Home » Tutorials » How to show an example</span>
</div>
<div id="main">
<div id="buttons">
<a class="btn" href="">Recent</a>
</div>
<div class="form-main">
<form class="form-wrapper">
<input type="text" id="search" placeholder="Search for tutorials ...">
<select>
<option value="7" selected="selected">All</option>
<option value="1">Newbie</option>
<option value="2">Beginner</option>
<option value="3">Novice</option>
<option value="4">Educated</option>
<option value="5">Expert</option>
<option value="6">Professional</option>
</select>
<input type="submit" value="Search" id="submit">
</form>
</div>
</div>
</div>
Here is the css code:
#topnav {
background-color: #f2f2f2;
border-radius: 5px 5px 0 0;
display: block;
height: 30px;
line-height: 25px;
padding: 5px;
}
#main {
padding: 5px 15px;
}
#buttons {
text-align: center;
}
.form-main {
background-color: #f6f6f6;
border-color: #dedede #bababa #aaa;
border-radius: 3px;
padding: 8px;
}
.btn {
background: none repeat scroll 0 0 #2972a3;
border-radius: 5px;
color: #ffffff;
font-family: Arial;
font-size: 17px;
padding: 10px 20px;
text-decoration: none;
}
You is positioned after the size of its parent, #buttons, which get its height based of the height of your content, which is 20px, but the real height of your is 40px, which means 10px, both top and bottom, will be outside #buttons div.
Try adding display: inline-block to your button class (.btn) to make the parent get the size including the padding.
Check it out here: http://jsfiddle.net/yc31unad/
add display:inline-block; to your button style
.btn {
background: none repeat scroll 0 0 #2972a3;
border-radius: 5px;
color: #ffffff;
font-family: Arial;
font-size: 17px;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
}

Drop Downs Disappear & Can't Center Button

I'm admitting right at the start: this is my first attempt at HTML/CSS coding. So please excuse my code's messiness.
I have two problems: 1. When I shrink my browser window small enough to see a scroll bar, my three drop down menus disappear. 2. I am trying to center my button (Find Resources), but can't figure it out. I've tried auto-ing my left and right margins, I tried text aligning, but it messed up the placement of my three boxes (which have a width of 200px).
Thanks for any help someone can offer!
HTML:
<div id="resource-wrapper">
<div id="content">
<p class="resource-p">Welcome to Our Resource Center.</p>
<p class="resource-p">How may we help you?</p>
</div>
<div id=buttons-div>
<div id=select>
<select class="dropdown" name="field_related_brands_nid">
<option value="All" selected="selected">Any</option>
<option value="2511">Sample</option>
</select>
<select class="dropdown-2" name="field_related_technology_nid">
<option value="All" selected="selected">Any</option>
<option value="444">Sample</option>
</select>
<select class="dropdown-3" name="field_resource_type_value_many_to_one">
<option value="All" selected="selected">Any</option>
<option value="multimedia">Sample</option>
</select>
</div>
<div id=buttons>
<img src="Images/Buttons1.jpg" class="resource-image">
<img src="Images/Buttons2.jpg" class="resource-image">
<img src="Images/buttons3.jpg" class="resource-image">
</div>
<button type="submit" class="resource-p1">Find Resources</button>
</div>
</div>
CSS:
#resource-wrapper {
width: 850px;
margin: 0 auto;}
#content {
background-color: #669bcf;
padding: 1px;
width: 100%;}
.resource-p {
text-align: center;
font-size: 30px;
font-family: sans-serif;
color: white;
line-height: 15px}
#buttons-div {
position: relative;
width: 850px;}
#select {
position: fixed;
margin-top: 214px;
width: 850px;}
.dropdown {
width: 160px;
margin-left: 78px;}
.dropdown-2 {
width: 125px;
margin-left: 115px;}
.dropdown-3 {
width: 95px;
margin-left: 148px;}
.resource-image {
margin: 50px 0 0 58px;}
.resource-p1 {
padding: 16px 18px 13px 18px;
margin: 20px;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;}
Your Dropdowns shouldn't stack as nothing is responsive in your site. If they have a set width like width: 800px; They should be fine. However make sure to have all your id's surrounded with a quote:
<div id=buttons-div>
should be
<div id="buttons-div">
To Center your Resource Button:
.resource-p1 {
margin: 12px auto;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;
display: block;
}
DEMO
1) Change #select's position from fixed to absolute
2) Wrap your button in a container and give that container text-align:center
HTML
<div id="find-resources-container">
<button type="submit" class="resource-p1">Find Resources</button>
</div>
CSS
#find-resources-container {
text-align:center
}

CSS Select box arrow style

I want to remove the default arrow from the select box and want to use custom icon. From the previous answers on SO, I have found out that it is not possible (to make it work with major browsers). Only possibility is to wrap the select inside a div, and set its width more than the div width and setting overflow: hidden.
I am trying following, but it does not work. What I'm doing wrong?
.selectParent {
width: 80px;
overflow: hidden;
}
.selectParent select {
width: 100px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 2px 30px 2px 2px;
border: none;
background: transparent url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat right center;
}
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
JSFiddle:
http://jsfiddle.net/gcPmC/
Please follow the way like below:
.selectParent {
width:120px;
overflow:hidden;
}
.selectParent select {
display: block;
width: 100%;
padding: 2px 25px 2px 2px;
border: none;
background: url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") right center no-repeat;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
.selectParent.left select {
direction: rtl;
padding: 2px 2px 2px 25px;
background-position: left center;
}
/* for IE and Edge */
select::-ms-expand {
display: none;
}
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
<br />
<div class="selectParent left">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
Try to replace the
padding: 2px 30px 2px 2px;
with
padding: 2px 2px 2px 2px;
It should work.