I'm making a web-app and came accross an interesting thing.
So I have a wrapper div with other divs in it. The wrapper has the following formating:
#ready{
height:568px;
white-space: nowrap;
}
their children divs have this:
.theme{
overflow: hidden;
position:relative;
display: inline-block;
height:568px;
width:320px;
text-align: center;
background-color: #FFF;
}
It works in firefox and chrome, the divs are next to each other as intended. I have to add float:left to .theme to make it work in Safari. Although when I add float:left Mobile Safari will break the divs to new lines.
Is this a bug, or am I doing something wrong? Any ideas, workarounds?
[EDIT]
Added html
<div id="ready">
<div id="welcome"class="theme active">
...
</div>
<div id="cat"class="theme">
...
</div>
<div id="minap"class="theme">
...
</div>
<div id="minecraft"class="theme">
...
</div>
<div id="padthai"class="theme">
...
</div>
<div id="orange"class="theme">
...
</div>
<div id="bszn"class="theme">
...
</div>
</div>
Since you've tried variations of float: left, display: inline-block, position: relative and position: absolute to get your row to stay in one line, but it always breaks into two lines on one device/browser or another, maybe a table layout will achieve your goal.
You can use either the HTML <table> element or CSS table properties. In my example below I've gone with CSS.
http://jsfiddle.net/w01ckufb/2/
HTML
<div id="container">
<div id="ready">
<div id="welcome"class="theme active">IMAGE</div>
<div id="cat"class="theme">IMAGE</div>
<div id="minap"class="theme">IMAGE</div>
<div id="minecraft"class="theme">IMAGE</div>
<div id="padthai"class="theme">IMAGE</div>
<div id="orange"class="theme">IMAGE</div>
<div id="bszn"class="theme">IMAGE</div>
</div><!-- end .ready -->
</div><!-- end #container -->
CSS
#container {
display: table;
width: 4000px;
border-spacing: 15px;
}
#ready{
display: table-row;
border: 2px solid red;
}
.theme {
display: table-cell;
height: 568px;
width: 820px;
text-align: center;
background-color: #FFF;
border: 2px dashed blue;
}
Hope this helps. If you have any questions leave a comment below.
Related
I need this type of page
Which shows achievements of a particular individual on yearly basis, as you can see it is all dynamic, if there are tho achievements, two rows are shown and so on. I am able to produce this, .
But I am not able to get these dots (or circles). I tried with left-border border-image and so on, but it would all break, because it is all dynamic, and any year can have as little as one achievement (or none, in that case it won't show up) or as many as tens (we don't have any max limit on this, but it can be many). So, if I do something with a image, it all breaks down.
Here's the page
<div class="achievements-details-container">
#foreach (var group in groupedModel)
{
<div class="achievements-details-group">
#for (var i = 0; i < group.Count(); i++)
{
var item = group.ElementAt(i);
<div class="achievements-details">
<div class="achievements-details-main">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-1">
#(i == 0 ? item.Year.ToString() : string.Empty)
</div>
<div class="achievement-title-before">
</div>
<div class="col-md-4 achievement-title">
#item.Title
</div>
<div class="col-md-1 smaller-padding-left">
<a href="#">
<img src="#Url.Content("~/Images/achievement_arrow.png")" alt="achievement_arrow" class="achievement-arrow-open" /></a>
</div>
<div class="col-md-3">
#item.SmallSummary
</div>
<div class="col-md-2 achievements-action-buttons no-padding">
<div class="">
#{Html.RenderPartial("_EditDiv", item.StatusID == (int)VersionStatus.Draft);}
</div>
</div>
</div>
</div>
</div>
}
</div>
}
</div>
The CSS
.achievements-details-container{
}
.achievements-details{
}
.achievements-details-main{
}
.achievement-title{
font-family: Tahoma, Arial, Sans-Serif;
font-weight: 600;
}
.achievements-details-group
{
border-bottom: 1px solid #F0F0F0;
margin-top: 1%;
}
.achievement-title-before:before
/* This is the css that is giving me the border line, I don't know how to add css for that desired circle here */
/* I tried setting the content to something like '\2022' but it turned out terrible*/
/* I have that circle image as achievement_circle.png */
{
content: '';
border-right: 2px solid #EB5B1D;
height: 500%;
position: absolute;
margin-top: -1%;
}
.achievements-details
{
margin-bottom: 1%;
}
.achievements-action-buttons{
}
.no-padding
{
padding-left: 0px !important;
padding-right: 0px !important;
}
.small-padding-left
{
padding-left: 8%;
}
.smaller-padding-left
{
padding-left: 4%;
}
.xx-small-padding-left
{
padding-left: 2%;
}
You might be able to generate this using the :after pseudo element.
Something like:
.achievement-title-before:after {
content: "";
position: absolute;
/*Set height and width*/
height: 30px;
width: 30px;
/*make it circular, as well as have a background color*/
border-radius: 50%;
background: tomato;
/*position this accordingly*/
left: 0px;
top: 5px;
}
Although, you may need to alter the positioning with the left: and top: values
I'm using the technique in this article to add momentum/intertia scrolling to an element.
html:
<h1>My title</h1>
<div class="container">
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
<div class="cause">
<div class="cause-content">
<h2>things</h2>
</div>
</div>
</div>
CSS:
body{
overflow: hidden;
}
.container{
margin-top: 5em;
overflow-x: scroll;
white-space: nowrap;
width: 100%;
height: 100%;
-webkit-overflow-scrolling: touch;
}
.cause{
/* prettify */
background: blue;
color: white;
text-align:center;
/* real shit */
display: inline-block;
width: 260px
}
This works, but the problem is that it takes other elements with it! My title scrolls off with it. This happens even if I add position: fixed (probably because fixed isn't fully supported on iOS Safari.
Does anybody know of a way to get inertia scrolling working while still jeeping the other elements in the right place?
I solved this by using the code in this pen. The important bit seems to be the whitespace: no-wrap bit.
HTML:
<div class="wrapper">
item 1
item 2
item 3
item 4
item 5
item 6
</div>
CSS:
body {
background-color: #333;
}
.wrapper {
width: 320px;
white-space: nowrap;
overflow-y: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
padding: 1rem;
background-color: #ccc;
}
.internal {
display: inline;
background-color: wheat;
&:nth-child(odd) {
background-color: hotpink;
}
}
Is it possible to set a checkbox instead of a split button in a split-button-list in jquery-mobile??
It seems to be easy to change it to be another button, but checkbox..
I want my checkbox to appear on a RIGHT side INSTEAD of a split button, not instead of a picture
Thanks for help..
Here is a DEMO FIDDLE
The UL does not use split icon, but instead an absolutely positioned DIV on the right with a checkbox inside. The CSS is used to position everything correctly:
<ul class="has-right-radio" data-role="listview" data-inset="true">
<li data-icon="false">
<a href="#">
<img src="http://view.jquerymobile.com/1.3.0/docs/_assets/img/album-p.jpg" />
<h3>Picture</h3>
<p>List item with thumbnail and right radio</p>
</a>
<div class="right-radio">
<input type="checkbox" name="checkbox-1a" id="checkbox-1a" checked="" />
<label for="checkbox-1a"></label>
</div>
</li>
</ul>
.has-right-radio .ui-link-inherit {
margin-right: 48px !important;
}
.right-radio {
position: absolute;
top: 0px; bottom: 0px; right: 0px;
width: 48px;
border-left: 1px solid rgb(204, 204, 204);
}
.right-radio .ui-checkbox input {
visibility: hidden;
}
.right-radio .ui-checkbox, .right-radio .ui-checkbox label {
position: absolute;
top: 0px; bottom: 0px; right: 0px; left: 0px;
}
.right-radio .ui-checkbox label {
background-image: none;
background-color: transparent;
border: 0;
}
.right-radio .ui-checkbox label .ui-btn-inner {
position: absolute;
top: 50%;
margin-top: -10px;
}
If you do not need the thumbnail, just leave out the IMG tag like the second LI in the fiddle.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<style>
.ui-btn-up-c{border:none;}
.ui-btn-hover-c{border:none;}
.ui-btn-hover-c:visited, .ui-btn-hover-c:hover, .ui-btn-hover-c a.ui-link-inherit { color:none;background:none;border:0px; }
</style>
</head>
<body>
<div data-role="page" id="myPage1">
<ul data-role="listview">
<li>
<div class="ui-grid-b">
<div class="ui-block-a" style="width: 30%;">
<div data-role="fieldcontain">
<img src="http://view.jquerymobile.com/1.3.0/docs/_assets/img/album-p.jpg">
</div>
</div>
<div class="ui-block-b" style="width: 60%;">
<div data-role="fieldcontain">
<h2>Phoenix</h2>
<p>Wolfgang Amadeus Phoenix Wolfgang Amadeus Phoenix Wolfgang Amadeus Phoenix</p>
</div>
</div>
<div class="ui-block-c" style="width: 6%; padding-top: 55px; float: right;">
<div style="float: right;">
<label>
<input name="checkbox-0 " type="checkbox">
</label>
</div>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>
Does the jQuery Mobile framework have a way of centering elements, specifically buttons? It looks like it defaults to left-aligning everything and I can't find a way (within the framework) to do this.
jQuery Mobile doesn't seem to have a css class to center elements (I searched through its css).
But you can write your own additional css.
Try creating your own:
.center-button{
margin: 0 auto;
}
example HTML:
<div data-role="button" class="center-button">button text</div>
and see what happens. You might need to set text-align to center in the wrapping tag, so this might work better:
.center-wrapper{
text-align: center;
}
.center-wrapper * {
margin: 0 auto;
}
example HTML:
<div class="center-wrapper">
<div data-role="button">button text</div>
</div>
An overkill approach: in inline css in the div did the trick:
style="margin:0 auto;
margin-left:auto;
margin-right:auto;
align:center;
text-align:center;"
Centers like a charm!
In the situation where you are NOT going to use this over and over (i.e. not needed in your style sheet), inline style statements usually work anywhere they would work inyour style sheet. E.g:
<div data-role="controlgroup" data-type="horizontal" style="text-align:center;">
The best option would be to put any element you want to be centered in a div like this:
<div class="center">
<img src="images/logo.png" />
</div>
and css or inline style:
.center {
text-align:center
}
I had found problems with some of the other methods mentioned here. Another way to do it would be to use layout grid B, and put your content in block b, and leave blocks a and c empty.
http://demos.jquerymobile.com/1.1.2/docs/content/content-grids.html
<div class="ui-grid-b">
<div class="ui-block-a"></div>
<div class="ui-block-b">Your Content Here</div>
<div class="ui-block-c"></div>
</div><!-- /grid-b -->
None of these answers alone worked for me. I had to combine them. (Maybe it is because I'm using a "button" tag and not a link typed as a button?)
In the HTML:
<div class="center-wrapper"><button type="submit" data-theme="b">Login</button></div>
In the CSS:
.center-wrapper {
text-align: center;
width: 300px;
margin:0 auto;
margin-left:auto;
margin-right:auto;
align:center;
text-align:center;
}
You can make the button an anchor element, and put it in a paragraph with the attribute:
align='center'
Worked for me.
To have them centered correctly and only for the items inside the wrapper .center-wrapper use this. ( all options combined should work cross browser ) if not please post a reply here!
.center-wrapper .ui-btn-text {
overflow: hidden;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
margin: 0 auto;
}
This works
HTML
<section id="wrapper">
<div data-role="page">
</div>
</section>
Css
#wrapper {
margin:0 auto;
width:1239px;
height:1022px;
background:#ffffff;
position:relative;
}
Adjust as your requirement
.ui-btn{
margin:0.5em 10px;
}
I've been looking at this for days, and I've searched and searched, maybe I just can't see the forest for the trees, but if anyone could shed some insight, I'd be really grateful.
Ok, I have this sticky footer that sort of is at the top of the page and scrolling down the page, the bar is always at the botom of the screen.
It works perfectly on my PC, but I can't see it on other PC's I test. Same exact set up, the paths to the images are there. I just can't seem to figureit out, I fee like I'm going banana's!
html code is:
<body id="home">
<div class="wrap">
<!-- Header -->
<div id="header">
</div>
<div id="slideshow-container">
<div id="slideshow"></div>
</div>
<!-- // Header -->
<div id="main" class="clearfix">
<!-- Content -->
<div id="content">
</div>
<!-- // Content -->
<!-- Sidebar -->
<div id="sidebar">
</div>
<!-- // sidebar -->
</div>
<!-- // Wrap end -->
<div id="footer" class="clearfix">
<div class="wrap">
<div class="clearfix">
</div>
</div>
</div>
Ok, you just can't see the images... what is going on - I feel so retarded!!
CSS:
body{
background: url(../images/bg_body.png) center 0 #ffffff repeat-x;
font-size: 62.5%;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
color: #666666;
padding: 0 0 50px 0;
height: 100%;
#footer{
background: url(../images/bg_footer.gif) center 0 repeat-x;
position: relative;
bottom: 0;
width: 100%;
left: 0;
right: 0;
z-index: 1000;
}
#footer .wrap{
background: url(../images/bg_footer_wrap.png) center 0 no-repeat;
padding: 7px 0 0 0;
height: 70px;
}
Take a good long look at CssStickyFooter.com and compare it to your code.
The immediately obvious thing is that your HTML is broken (body and wrap are never closed) and that ".clearfix" (not defined in posted CSS, btw) is applied all over the place.
Found a great sticky footer solution today. Hope it helps, seems to be the simplest solution to me:
<style type="text/css">
html,body {
height:100%
}
#wrapper {
min-height:100%;
margin-bottom:-150px; /* negative total computed height of footer */
}
#footer_padding {
height:150px; /* total computed height of footer */
}
#footer {
height:100px;
margin-top:50px;
}
</style>
<div id="wrapper">
<div>some content...</div>
<div id="footer_padding"></div>
</div>
<div id="footer"></div>
You will find on this github repository (Bredele css sticky footer) two versions of sticky footers : one with a header and an other one without.
Both these versions use display:table (works with IE8 and IE6/7 with polyfill) with no extra markups, no clearfix (instead CssStickyFooter) and a flexible content height.
Hope it'll be helpful!
Olivier