0

I am trying to hide an alert which is displayed inline using the slide function. It is displayed inline but the sliding doesn't happen inline like I intend it to happen. How can I make the sliding happen inline?

The following is the snippet with current code

$("#testDiv2").show();

$("#testDiv2").on('click', function () {
$("#testDiv2").hide('slide',{direction: 'left'}, 6000);
});

$(function() {
    if ($("#testDiv2").is(':visible')) 
     $("#testDiv2").css('display','inline-block'); 
});
#test,#testDiv,#testDiv2 { 
    display:inline-block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<div id="test">
A
<div id="testDiv2">
    <div id="testDiv" class="alert alert-success">Click to close</div>
</div>
B
</div>

Related posts:

  • I have seen this post which suggests to change to inline-block which doesn't solve the issue.
  • This self answered question is similar to mine but it is about displaying the next one inline not about the current one.

1 Answer 1

1

Well, I figured out that this piece of code will fix the inline problem for you, but there are still some layout issues. I'm working on it.

#test > div.ui-effects-wrapper {
   display: inline-block !important;
}

SNIPPET

$("#testDiv2").show();

$("#testDiv2").on('click', function() {
  $("#testDiv2").hide('slide', {
    direction: 'left'
  }, 6000);
});

$(function() {
  if ($("#testDiv2").is(':visible'))
    $("#testDiv2").css('display', 'inline-block');
});
#test,
#testDiv,
#testDiv2 {
  display: inline-block;
}
#test > div.ui-effects-wrapper {
  display: inline-block !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<div id="test">
  A
  <div id="testDiv2">
    <div id="testDiv" class="alert alert-success">Click to close</div>
  </div>
  B
</div>

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the answer. Can you please what ui-effects-wrapper is?
Making ui-effects-wrapper inline instead of inline-block makes it better but the sliding effect goes over A which is not I want it to do.
I'm not that familiar with jquery-ui but it seems like the ui-effects-wrapper (a wrapper for the sliding element) is being created during the animation process.
that wrapper is a real pain in the a.. :|
True. I have been trying too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.