How to avoid double borders on list of divs
Tags: jquery,css
Problem :
I have a list of divs which are used as a FAQ. Sometimes the divs are listed below each other, sometimes there is text between them. When they are listed below one other, I have this issue with double borders which I don't know how to solve.
See this fiddle.
HTML
<div class="faq">
<div class="faqheader">Toggle 1</div>
<div class="faqcontent">Content 1</div>
</div>
<p>Some text...</p>
<div class="faq">
<div class="faqheader">Toggle 2</div>
<div class="faqcontent">Content 2</div>
</div>
<p>Some text...</p>
<div class="faq">
<div class="faqheader">Toggle 3</div>
<div class="faqcontent">Content 3</div>
</div>
<div class="faq">
<div class="faqheader">Toggle 4</div>
<div class="faqcontent">Content 4</div>
</div>
CSS
.faq {width:200px;border: 1px solid #ddd;}
.faqheader {height:20px;font-weight: bold;cursor: pointer;}
.faqcontent {display:none;height:50px;}
The divs need to have a border: border:1px solid #ddd
The borders look fine when there's text between the divs (toggle 1 and 2), but when they are close together (toggle 3 and 4), it doesn't look very nice.
Changing the markup is not an option at this point. They are generated dynamically. Is there any way to fix this issue with either css or jquery?
Solution :
add this rule to your CSS
.faq + .faq
{
border-top: none;
}
Explanation: .faq
that comes directly after another .faq
dont get a top border.
- this is a pure CSS solution (without Script)
- it doesnt assume anithing about the layout (the div's dont have to be last childs of a container, or at some specific index)
- its fixes the double border issue even if their are multiple
.faq
one after each other. - its a cross browser solution.
See this Working Fiddle
CSS Howto..
I would suggest to create a class with name like .active and then use .addClass method. However take a look at the DEMO first. Here is the jQuery Code $('.active').css({...
You cannot control the drop down expansion direction. This is something the browser calculates. Perhaps you can try making some workaround. Make your own custom dropdown system? Maybe have a...
This is provided in Chartist using SMIL - http://gionkunz.github.io/chartist-js/examples.html#svg-path-animation. While this will work as is in Chrome - you'll probably need a shim for IE - SVG animation not working...
You can not neutralize CSS rules whithout overriding. So you have to do as you suggested in the answers above.
Of course, just use import in you style.less: @import "header.less"; @import "body.less"; @import "footer.less"; and the three less files will be compiled into the style.css Every import possibilities are listed...
$("td.time") select all table cells with class time not only those in that row. Add a reference to the row as the (second) context parameter just as you are doing...
you can do this like .x a {text-decoration:none;} here is the example js fiddle...
Your chosen book is a good one. Learning jQuery is also a good stepping stone to learning Javascript if you're starting out with only design experience; it's great if you're...
http://jsfiddle.net/fZse3/ <style> #col1, #col2 { float:left; width: 50%; } </style> <div id="col1"> <div> <div>title </div> <div>content </div> <div>name </div> <div>data </div> </div> <div> <div>title </div> <div>content...
$('div#link1').css('background-image', 'none'); From here : http://www.w3schools.com/css/pr_background-image.asp...
demo Basics Using :after we can inject content after each matched selector. The first selector matches any href attribute starting with //. This is for links that keep the same...
There are multiple ways One is to use attribute starts with selector - it will be better if you can enhance this with a element selector like $('div[id^="task-title-modal-"]') if all...
You may need this: .image_carousel { margin-top: 20px; box-shadow: 0px 0px 3px #000; } .image_carousel img{ float:left; width: 60px; } .image_carousel p{ float:left; } .clear { clear: both; } <div...
You can use display: inline-block; instead of display: block; in every class for the a elements. You can also add vertical-align: middle to have the links centered in the h1...
If you want to make transitions with box-shadow, the elements of the box-shadow must make "pairs" and must match the "class" of the shadow. Pixels and colors can be transitioned,...
Not sue if this meet your needs but one option would be to wrap the <button>s by a <div> and give that white-space: nowrap declaration. body > div { width:...
Two suggestions: You're essentially asking for a table-based layout, so you may as well use an HTML table. Each of your cells has a fixed width, and your PHP code...
Just of the top of my head, I think that if you're willing to use HTML5 and use the <input type="text" name="year" required> property, that you should be able to...
you may use flex : You can simply test adding these 2 rules to your style sheet: (snippet below to see by yourself :) ) .MainContent { display: flex; }...
Try wrapping the 'div' in an 'a' element: <a href="/user/id"><div>[field...]</div></a> Edit: This will make all the text appear as a link, so might want to add some CSS. Example: HTML:...
@thirtydot, The box width is fixed, both width and height. How do I use 4 corners with divs ? – Ibn Saeed Maybe I'm missing something, but if the...
Assuming the "Badge Name: " phrase is constant, one approach is using CSS :before pseudo element to generate the content as follows: EXAMPLE HERE .tag:before { content: "Badge Name: ";...
That is Font Awesome: https://fortawesome.github.io/Font-Awesome/icons/ Go there and search (ctrl+F) for "volume". Font Awesome is loaded on the first line of the CSS file: @import "//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"; If you want to...
Grids elements of Semantic UI got display: inline-block, so you can set white-space:nowrap to prevent that elements wrap in a row: <div class="features ui grid noMargin" style="overflow-y:auto;white-space:nowrap;"> <div class="four wide...
Something like this maybe? @media only screen and (max-width: 460px) { /* Force table to not be like tables anymore */ table, th, tbody, td, thead { display: block; width:...
Facebook seems to accomplish this by setting the CSS attribute "overflow: hidden" on the document body when a picture is displayed. I just tested it myself by adding the following...
update: This is an old answer, nowadays you want to go with an embedded browser in your app (*webkit projects etc.), but at the time of writing, no such technology...
You can run the search queries with the time code, then echo them after the search has finished with the time code coming first. $start = microtime(true); $searchdata = //Search...
DEMO This can be achieved simply by removing the fixed height widths. Elements with unspecified widths are set to width:auto which is usually the size of the elements contents....
Here is pure css approach with transition on hover #div1 { width: 300px; height: 300px; border: 2px black solid; position: relative; overflow: hidden; } #div2 img { position: absolute; top:...